snosniv <
[email protected]> wrote:
My CSV file has the row data like this:
"1 November 2022 11:00:27",156.0,24.2,15.7,131.6,13.6,7.0,
So when I chop up the row into elements I get the timestamp as just:
"1 November 2022 11:00:27"
So I have to further remove the quotes to get clock scan with format to work, by using:
set l1 [string length $my_DateTime]
set my_DateTime [string range $my_DateTime 1 [expr $l1 - 2]]
Is there a simpler way please?
Use the Tcllib CSV library. It handles the quirky quoting standard for
CSV files which you are not handling with what appears to be your own
custom attempt at parsing the CSV file..
I.e.:
package require csv
package require struct::queue
struct::queue q
set fd [open csvfile.csv RDONLY]
csv::readwqueue $fd q
close $fd
foreach row [q get [q size]] {
# do things with each row here -- and any CSV escaping quotes will be
# missing, but any quotes that actually form part of the data will be
# present
}
Do note that the above hoovers the entire CSV into memory all at once. Depending on the size of the csv, you may or may not want to hoover it
all in up front.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)