Skip to content

Commit c8a3513

Browse files
authored
Merge pull request #16 from jpfolch/jpfolch_dev
added chemstation encoding options
2 parents c9225a5 + 1b796f7 commit c8a3513

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/mocca2/parsers/chemstation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
from mocca2.classes import Data2D
55

6-
def parse_chemstation(path) -> Data2D:
6+
def parse_chemstation(path, encoding='utf-16') -> Data2D:
77
"""
88
Chemstation read and processing function.
99
"""
1010

1111
if os.path.isfile(path):
12-
raw = np.genfromtxt(path, delimiter=',', encoding='utf-16')
12+
raw = np.genfromtxt(path, delimiter=',', encoding=encoding)
1313
else:
14-
raw = np.genfromtxt(os.path.join(path, 'DAD1.CSV'), delimiter=',', encoding='utf-16')
14+
raw = np.genfromtxt(os.path.join(path, 'DAD1.CSV'), delimiter=',', encoding=encoding)
1515

1616

1717
time = raw[1:,0]

src/mocca2/parsers/wrapper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from mocca2.parsers.chemstation import parse_chemstation
66
from mocca2.parsers.labsolutions import parse_labsolutions
77

8-
def load_data2d(path: str, format: Literal['auto', 'empower', 'chemstation', 'labsolutions'] = 'auto') -> Data2D:
8+
def load_data2d(path: str, format: Literal['auto', 'empower', 'chemstation', 'labsolutions'] = 'auto', encoding = 'utf-16') -> Data2D:
99
"""
1010
Loads empower/chemstation/labsolutions file, returns 2D data
1111
@@ -31,15 +31,15 @@ def load_data2d(path: str, format: Literal['auto', 'empower', 'chemstation', 'la
3131
if path.lower().endswith('.arw'):
3232
data = parse_empower(path)
3333
elif path.lower().endswith('.csv') or path.lower().endswith('.d'):
34-
data = parse_chemstation(path)
34+
data = parse_chemstation(path, encoding=encoding)
3535
elif path.lower().endswith('.txt'):
3636
data = parse_labsolutions(path)
3737
else:
3838
raise Exception("Unknown file format in load_data2D(), consider specifying the format instead of using `auto`")
3939
elif format == 'empower':
4040
data = parse_empower(path)
4141
elif format == 'chemstation':
42-
data = parse_chemstation(path)
42+
data = parse_chemstation(path, encoding=encoding)
4343
elif format == 'labsolutions':
4444
data = parse_labsolutions(path)
4545

0 commit comments

Comments
 (0)