1
0
forked from IPKM/nmreval

Merge pull request 'replace semicolon and commas with spaces in csv; closes #23' (#24) from csv_broken into master

Reviewed-on: IPKM/nmreval#24
This commit is contained in:
Dominik Demuth 2023-03-24 10:05:43 +00:00
commit df9b302f9d

View File

@ -1,5 +1,6 @@
import pathlib import pathlib
import re import re
from io import BytesIO
from itertools import islice from itertools import islice
import numpy as np import numpy as np
@ -99,7 +100,10 @@ class AsciiReader:
y = list(range(1, max(self.width))) y = list(range(1, max(self.width)))
cols = x + y + yerr 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: if raw_data.ndim == 1:
# only one row or column # only one row or column
if len(self.data) == 1: if len(self.data) == 1: