diff options
-rwxr-xr-x | scripts/csv2sto.py | 6 | ||||
-rwxr-xr-x | scripts/plotcsv.py | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/scripts/csv2sto.py b/scripts/csv2sto.py index 4275fb1..c43a990 100755 --- a/scripts/csv2sto.py +++ b/scripts/csv2sto.py @@ -121,7 +121,11 @@ def main(): fd_sto.write("\n") fds_csv = [ open(f_csv, 'r') for f_csv in fs_csv ] - crs = [ csv.reader(fd_csv, delimiter=',') for fd_csv in fds_csv ] + crs = [] + for fd_csv in fds_csv: + dialect = csv.Sniffer().sniff(fd_csv.read(1024)) + fd_csv.seek(0) + crs.append(csv.reader(fd_csv, dialect)) times = np.zeros((tot_nRows, len(fds_csv))) vals = np.zeros((tot_nRows, len(fds_csv))) diff --git a/scripts/plotcsv.py b/scripts/plotcsv.py index fd6d084..1d26354 100755 --- a/scripts/plotcsv.py +++ b/scripts/plotcsv.py @@ -41,7 +41,10 @@ def plot(x, y, x_max, y_max, x_name, y_name, title, cubic, linear, xnew=None, f= def read_and_plot_csv(csv_file, cubic, linear, x_max=X_MAX, y_max=Y_MAX): print("Reading data...") - reader = csv.reader(open(csv_file, 'r'), delimiter=',') + cf = open(csv_file, 'r') + dialect = csv.Sniffer().sniff(cf.read(1024)) + cf.seek(0) + reader = csv.reader(cf, dialect) x_name,y_name = reader.next() # header line X = np.array([[float(_x), float(_y)] for _x,_y in reader ]) |