X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcsvtodiag.tcl;h=12e263c45ede740f2bf5d93754aaf4ced5885aa7;hp=6dcd1be4986c28dbda69a4351cd37cde15a4a71f;hb=0a479be82be90639f4e37c4ead12baca543e88bf;hpb=d5a4d0d6a476429a3588e8e7d9e31094c28ef204 diff --git a/src/csvtodiag.tcl b/src/csvtodiag.tcl index 6dcd1be..12e263c 100644 --- a/src/csvtodiag.tcl +++ b/src/csvtodiag.tcl @@ -94,3 +94,55 @@ YAZ_END_CDECL close $hfile } +proc csvto_xml {csvfname xmlfname id} { + set xfile [open $xmlfname w] + set csv [open $csvfname r] + + puts $xfile "" + puts $xfile "" + puts $xfile {} + puts $xfile {} + puts $xfile {} + puts $xfile {} + puts $xfile {} + puts $xfile {Code} + puts $xfile {Text} + puts $xfile {} + puts $xfile {} + puts $xfile {} + + set lineno 0 + while {1} { + incr lineno + set cnt [gets $csv line] + if {$cnt < 0} { + break + } + if {[regexp {([0-9]+)[^\"]*"([^\"]*)"} $line s code msg]} { + puts $xfile {} + puts $xfile {} + puts $xfile $code + puts $xfile {} + puts $xfile $msg + puts $xfile {} + puts $xfile {} + } + } + puts $xfile {} + puts $xfile {} + puts $xfile {} + + close $xfile + close $csv +} + +if {[llength $argv] >= 4} { + set alias {} + if {[llength $argv] >= 5} { + set alias [lindex $argv 4] + } + csvtodiag [list [lindex $argv 0] [lindex $argv 1] [lindex $argv 2]] \ + [lindex $argv 3] $alias +} elseif {[llength $argv] == 3} { + csvto_xml [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] +} \ No newline at end of file