From 552cec3666f566164a736e31d3aa37fa9c0c257a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 12 Feb 2013 15:29:12 +0100 Subject: scripts/csv2sto.py: Fix column number detection once again --- scripts/csv2sto.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') 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: -- cgit v1.2.3-54-g00ecf