summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-02-12 15:29:12 +0100
committerTobias Klauser <tklauser@distanz.ch>2013-02-12 15:29:12 +0100
commit552cec3666f566164a736e31d3aa37fa9c0c257a (patch)
treeca8b3b79e9b1f9b8f142398893da56f43e9ad824
parent00e307ff827229c6f86021b846a9ff1ddf0c5e55 (diff)
scripts/csv2sto.py: Fix column number detection once again
-rwxr-xr-xscripts/csv2sto.py8
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: