| Description: |
This patch applies to read2matrix, but each API that
reads from a channel needs to account for multiline CSV
data.
Index: csv.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/csv/csv.tcl,v
retrieving revision 1.22
diff -u -r1.22 csv.tcl
--- csv.tcl 30 Sep 2005 23:03:20 -0000 1.22
+++ csv.tcl 17 Jan 2006 01:10:58 -0000
@@ -166,10 +166,19 @@
}
}
+ set data ""
while {![eof $chan]} {
if {[gets $chan line] < 0} {continue}
- if {$line == {}} {continue}
- Split2matrix $alternate $m $line $sepChar $expand
+ # Why skip empty lines? They may be in data.
+ #if {$line == {}} {continue}
+ append data $line
+ if {[regexp -all \" $data] % 2} {
+ # Odd number of quotes - must have embedded
newline
+ append data \n
+ continue
+ }
+ Split2matrix $alternate $m $data $sepChar $expand
+ set data ""
}
return
}
|