pychemstation 0.9.0__py3-none-any.whl → 0.9.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,7 @@ from aghplctools.ingestion.text import (
15
15
  _signal_table_re,
16
16
  chunk_string,
17
17
  )
18
+ from pandas._libs.parsers import EmptyDataError
18
19
  from result import Err, Ok, Result
19
20
 
20
21
  from ..analysis.chromatogram import AgilentHPLCChromatogram
@@ -69,6 +70,16 @@ class CSVProcessor(ReportProcessor):
69
70
  """
70
71
  super().__init__(path)
71
72
 
73
+ def find_csv_prefix(self) -> str:
74
+ files = [f for f in os.listdir(self.path) if os.path.isfile(os.path.join(self.path, f))]
75
+ for file in files:
76
+ if "00" in file:
77
+ name, _, file_extension = file.partition(".")
78
+ if "00" in name and file_extension.lower() == "csv":
79
+ prefix, _, _ = name.partition("00")
80
+ return prefix
81
+ raise FileNotFoundError("Couldn't find the prefix for CSV")
82
+
72
83
  def process_report(self) -> Result[AgilentReport, AnyStr]:
73
84
  """
74
85
  Method to parse details from CSV report.
@@ -76,8 +87,11 @@ class CSVProcessor(ReportProcessor):
76
87
  :return: subset of complete report details, specifically the sample location, solvents in pumps,
77
88
  and list of peaks at each wavelength channel.
78
89
  """
79
- labels = os.path.join(self.path, "REPORT00.CSV")
80
- if os.path.exists(labels):
90
+ prefix = self.find_csv_prefix()
91
+ labels = os.path.join(self.path, f"{prefix}00.CSV")
92
+ if not os.path.exists(labels):
93
+ raise ValueError("CSV reports do not exist, make sure to turn on the post run CSV report option!")
94
+ elif os.path.exists(labels):
81
95
  df_labels: Dict[int, Dict[int:AnyStr]] = pd.read_csv(
82
96
  labels, encoding="utf-16", header=None
83
97
  ).to_dict()
@@ -93,12 +107,15 @@ class CSVProcessor(ReportProcessor):
93
107
  elif val == "Number of Signals":
94
108
  num_signals = int(df_labels[1][pos])
95
109
  for s in range(1, num_signals + 1):
96
- df = pd.read_csv(
97
- os.path.join(self.path, f"REPORT0{s}.CSV"),
98
- encoding="utf-16",
99
- header=None,
100
- )
101
- peaks = df.apply(lambda row: AgilentPeak(*row), axis=1)
110
+ try:
111
+ df = pd.read_csv(
112
+ os.path.join(self.path, f"{prefix}0{s}.CSV"),
113
+ encoding="utf-16",
114
+ header=None,
115
+ )
116
+ peaks = df.apply(lambda row: AgilentPeak(*row), axis=1)
117
+ except EmptyDataError:
118
+ peaks = []
102
119
  try:
103
120
  wavelength = df_labels[1][pos + s].partition(",4 Ref=off")[0][
104
121
  -3:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pychemstation
3
- Version: 0.9.0
3
+ Version: 0.9.1
4
4
  Summary: Library to interact with Chemstation software, primarily used in Hein lab
5
5
  Project-URL: Documentation, https://pychemstation-e5a086.gitlab.io/pychemstation.html
6
6
  Project-URL: Repository, https://gitlab.com/heingroup/device-api/pychemstation
@@ -8,10 +8,11 @@ Author-email: lucyhao <hao.lucyy@gmail.com>
8
8
  License-File: LICENSE
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3.9
11
12
  Classifier: Programming Language :: Python :: 3.10
12
13
  Classifier: Programming Language :: Python :: 3.11
13
14
  Classifier: Programming Language :: Python :: 3.12
14
- Requires-Python: >=3.9
15
+ Requires-Python: ~=3.9
15
16
  Requires-Dist: aghplctools==4.8.6
16
17
  Requires-Dist: coverage>=7.6.1
17
18
  Requires-Dist: matplotlib>=3.7.5
@@ -2,7 +2,7 @@ pychemstation/__init__.py,sha256=Sc4z8LRVFMwJUoc_DPVUriSXTZ6PO9MaJ80PhRbKyB8,34
2
2
  pychemstation/analysis/__init__.py,sha256=dcX7OeHoKdyrECHRCSXgKZN81nOXSAmZRxXzRT0jpDc,126
3
3
  pychemstation/analysis/base_spectrum.py,sha256=t_VoxAtBph1V7S4fOsziERHiOBkYP0_nH7LTwbTEvcE,16529
4
4
  pychemstation/analysis/chromatogram.py,sha256=cBfLh58PrBZMg9-u5o_Q-FCuu3MlB0q0ZFm9_2uaciU,3270
5
- pychemstation/analysis/process_report.py,sha256=Bts92n_Cm5BuDAPvemblCbs-KBWivEouRMN_ddX4ezo,12498
5
+ pychemstation/analysis/process_report.py,sha256=uW5sqAIw_YR3-MHaid1dDEF8qdys-ZEZfa-1vqV-nms,13363
6
6
  pychemstation/control/README.md,sha256=_7ITj4hD17YIwci6UY6xBebC9gPCBpzBFTB_Gx0eJBc,3124
7
7
  pychemstation/control/__init__.py,sha256=uzfsVAGDhMP6SyV10KAH264ytDLMsMRZXRK5XhWS-rc,102
8
8
  pychemstation/control/hplc.py,sha256=mV-IO-6wdzB7MuV5LcZYwb4yZibBgEKX2LtbJ9WiKNw,12304
@@ -31,7 +31,7 @@ pychemstation/utils/sequence_types.py,sha256=T0IP2iMqorUrdzH4at9Vsmmb3SCAEmN4z1c
31
31
  pychemstation/utils/spec_utils.py,sha256=lS27Xi4mFNDWBfmBqOoxTcVchPAkLK2mSdoaWDOfaPI,10211
32
32
  pychemstation/utils/table_types.py,sha256=inOVpwSsic31VdVdJkfuq35QfKd7PoNoXY1QnOxZ6Sw,3235
33
33
  pychemstation/utils/tray_types.py,sha256=9yLRIBn3IPVMbhrFqJQJ5gCQJI7H9DD2cdIFQDp2-8k,5184
34
- pychemstation-0.9.0.dist-info/METADATA,sha256=Kjo6hY93bhBfQiiqcQb69tAZEIiqrW0D5jfZ_l6LxEk,5931
35
- pychemstation-0.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
- pychemstation-0.9.0.dist-info/licenses/LICENSE,sha256=9bdF75gIf1MecZ7oymqWgJREVz7McXPG-mjqrTmzzD8,18658
37
- pychemstation-0.9.0.dist-info/RECORD,,
34
+ pychemstation-0.9.1.dist-info/METADATA,sha256=ypplz0GWS-erPPVfmLxVQXR6vm7__Mo8UIoSs1VD24o,5981
35
+ pychemstation-0.9.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
+ pychemstation-0.9.1.dist-info/licenses/LICENSE,sha256=9bdF75gIf1MecZ7oymqWgJREVz7McXPG-mjqrTmzzD8,18658
37
+ pychemstation-0.9.1.dist-info/RECORD,,