diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-02-12 15:29:12 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-02-12 15:29:12 +0100 |
commit | 552cec3666f566164a736e31d3aa37fa9c0c257a (patch) | |
tree | ca8b3b79e9b1f9b8f142398893da56f43e9ad824 /scripts | |
parent | 00e307ff827229c6f86021b846a9ff1ddf0c5e55 (diff) |
scripts/csv2sto.py: Fix column number detection once again
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/csv2sto.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/csv2sto.py b/scripts/csv2sto.py index d212494..97d768b 100755 --- a/scripts/csv2sto.py +++ b/scripts/csv2sto.py @@ -81,11 +81,15 @@ def main(): tot_nCols = 1 # initial time column (as we omit it when taking data from each CSV) for f_csv in fs_csv: fd = open(f_csv, 'r') + dialect = csv.Sniffer().sniff(fd.read(1024)) + fd.seek(0) + csv_reader = csv.reader(fd, dialect) nRows = nCols = 0 - for line in fd: + for line in csv_reader: if nRows == 0: - nCols = len(line.split(',')) + nCols = len(line) + print("nCols: {}".format(nCols)) nRows += 1 if tot_nRows == 0: |