replace semicolon and commas with spaces in csv; closes #23

This commit is contained in:
Dominik Demuth 2023-03-24 11:03:50 +01:00
parent de9464ef9f
commit 4e0ff4eddd

View File

@ -1,5 +1,6 @@
import pathlib
import re
from io import BytesIO
from itertools import islice
import numpy as np
@ -99,7 +100,10 @@ class AsciiReader:
y = list(range(1, max(self.width)))
cols = x + y + yerr
raw_data = np.genfromtxt(self.fname, usecols=cols, missing_values='--')
with self.fname.open('rb') as fh:
tmp_ = re.sub(b'[;,]', b' ', fh.read())
raw_data = np.genfromtxt(BytesIO(tmp_), usecols=cols, missing_values='--')
del tmp_
if raw_data.ndim == 1:
# only one row or column
if len(self.data) == 1: