Created
April 8, 2016 19:54
-
-
Save cmosguy/b3c34ae24ac3ff99bb7e37f8c7eed352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package require csv | |
package require struct::matrix | |
proc parseCsv {csvFile} { | |
catch { | |
#doing a lot of reloading on the data matrix | |
#need to delete the data command before issuing the | |
#struct command again | |
rename data {} | |
} | |
::struct::matrix data | |
set chan [open $csvFile r] | |
csv::read2matrix $chan data , auto | |
close $chan | |
puts "Processing CSV: $csvFile" | |
set rows [data rows] | |
puts "Total rows: $rows" | |
for {set row 0} {$row < $rows} {incr row} { | |
set dataRow [data get row $row] | |
puts "row $row: $dataRow" | |
} | |
#remember to destroy the matrix!!!! | |
data destroy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment