Mass Table entry

  • Creator
  • #49631
    Gordon Wilkinson

    I need to create a table that has upwards of 1,000 entries.  Is it possible to upload from an outside source, say Excel/Access, or will I need to manually type each entry directly into Cloverleaf?

Viewing 2 reply threads
  • Author
    • #62795
      John Hamilton

      Not recomded I”m sure but i have edited the file on occasion.

      here is a script that you can try to create the file for yourself. It is not well documented and only does basic errror checking.

    • #62796
      Nate Kruse

      Create a sample table.  Go to the table directory on the server and look at the table format.  Then you can use a tcl script (with reading in your csv values) and create that file format.

      Here is a script I used.  Test your output though as I had several revisions of this and I hope this was the latest one.

      proc create_table_from_file {  } {

      #Set file names

      set filedate [clock format [clock seconds] -format “%B %d, %Y %I:%M:%S %p”]

      set input_dir “C:/Data_Files/”

      #set input_dir [glob -dir $input_dir *.csv]

      #set read_file [lindex $input_dir 0] ;#Assuming one file is to be read

      set read_file “C:/Data_Files/diagnosiscodes_master.txt”

      set output_file “C:/Data_Files/TumorReg_DiagCodes_Lookup_master.tbl”

      set fldSeparator “#”

      set output “”

      set newline “n”

      #Does the read file exist?

      if {[file exists $read_file] == 0} {

      #1 is success, 0 is failure

      puts stdout “File Does Not Exist:  $read_file.”



      #Can we open the original file?

      if [catch {open $read_file r}] {

      puts stdout “Error Opening File:  $read_file.”


      } else {

      set dataIn [open $read_file r]

      puts stdout “Reading File $read_file…”


      #Get and Set file data

      set filedata [read $dataIn]

      #Get length of file

      set filelen [string length $filedata]

      #Does file have data?

      if {$filelen == 0} {

      puts stdout “Message length in $read_file is 0.  No data to be processed.”

      } else {

      #Create a new file to write results to. Can we open it?

      if [catch {open $output_file w}] {

      puts stdout “Error Opening File:  $output_file.”


      } else {

      set dataOut [open $output_file w]

      puts stdout “Opening File $output_file…”


      #Output the header information for the table.

      set output “# Translation lookup table$newline”

      append output “#$newline”

      append output “prologue$newline”

      append output ”    who: Hospital – imported table$newline”

      append output ”    date: $filedate$newline”

      append output ”    outname: output$newline”

      append output ”    inname: input$newline”

      append output ”    bidir: 0$newline”

      append output ”    type: tbl$newline”

      append output ”    version: 3.0$newline”

      append output “end_prologue$newline”

      set record [split $filedata n]

      foreach line $record {

      if {$line != “”} {

      set linevalue [split $line “,”]

      puts stdout “linevalue = $linevalue”

      set fldOne [lindex $linevalue 0]

      set fldTwo [lindex $linevalue 1]

      set checkval [string range $fldOne 0 3]

      if {$checkval == “dflt”} {

      #Row is default ->  dflt=$fldOne

      if {$fldOne == “dflt”} {

      #write the values to the output file in this order

      append output $fldSeparator $newline

      append output “dflt=$fldTwo$newline”


      } else {

      if {$fldOne != “” && $fldTwo != “”} {

      #write the values to the output file in this order

      append output $fldSeparator $newline

      append output $fldOne $newline

      append output $fldTwo $newline






      puts stdout “Finished Processing!”

      puts $dataOut $output

      close $dataOut

      close $dataIn


    • #62797
      Gordon Wilkinson

      I found a way to upload an electronic file.  I copied the table off the engine and simply cut and paste from a .txt file (created from our HIS)the exact format which is




      and then copied back up to the engine.  I tested and it works.

Viewing 2 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
Topic Tags