From 9d6c1bec57593f5d4dd8dbe31d6ca9377ea6679c Mon Sep 17 00:00:00 2001 From: Nihadness <1992.nihad@gmail.com> Date: Fri, 16 Mar 2018 11:14:33 +0100 Subject: [PATCH 1/3] CSV Parser in Cobas Taqman 48 Instrument Interface. --- .../lims/exportimport/instruments/__init__.py | 2 +- .../instruments/rochecobas/taqman/model48.py | 19 ++++++++++++++----- .../rochecobas/taqman/model48_import.pt | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bika/lims/exportimport/instruments/__init__.py b/bika/lims/exportimport/instruments/__init__.py index 8f2f95f6c0..a1dde654e8 100644 --- a/bika/lims/exportimport/instruments/__init__.py +++ b/bika/lims/exportimport/instruments/__init__.py @@ -100,7 +100,7 @@ # ['generic.xml', ''], ['horiba.jobinyvon.icp', 'HoribaJobinYvonCSVParser'], ['rigaku.supermini.wxrf', 'RigakuSuperminiWXRFCSVParser'], - ['rochecobas.taqman.model48', 'RocheCobasTaqmanRSFParser'], + ['rochecobas.taqman.model48', 'RocheCobasTaqmanParser'], ['rochecobas.taqman.model96', 'RocheCobasTaqmanRSFParser'], ['thermoscientific.arena.xt20', 'ThermoArena20XTRPRCSVParser'], ['thermoscientific.gallery.Ts9861x', 'ThermoGallery9861xTSVParser'], diff --git a/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py b/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py index 7e1f41576f..911b4034d6 100644 --- a/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py +++ b/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py @@ -19,17 +19,24 @@ title = "Roche Cobas - Taqman - 48" -class RocheCobasTaqmanRSFParser(InstrumentCSVResultsFileParser): - def __init__(self, rsf): +class RocheCobasTaqmanParser(InstrumentCSVResultsFileParser): + + def __init__(self, rsf, fileformat=None): InstrumentCSVResultsFileParser.__init__(self, rsf) self._columns = [] # The different columns names self._values = {} # The analysis services from the same resid self._resid = '' # A stored resid self._rownum = None self._end_header = False + self._fileformat = fileformat def _parseline(self, line): - sline = line.replace('"', '').split('\t') + + if self._fileformat == "csv": + sline = line.replace('"', '').split(',') + else: + sline = line.replace('"', '').split('\t') + if len(sline) > 0 and not self._end_header: self._columns = sline self._end_header = True @@ -113,7 +120,9 @@ def Import(context, request): if not hasattr(infile, 'filename'): errors.append(_("No file selected")) if fileformat == 'rsf': - parser = RocheCobasTaqmanRSFParser(infile) + parser = RocheCobasTaqmanParser(infile) + if fileformat == 'csv': + parser = RocheCobasTaqmanParser(infile, "csv") else: errors.append(t(_("Unrecognized file format ${fileformat}", mapping={"fileformat": fileformat}))) @@ -166,7 +175,7 @@ def Import(context, request): return json.dumps(results) -class BeckmancoulterAccess2RSFParser(RocheCobasTaqmanRSFParser): +class BeckmancoulterAccess2RSFParser(RocheCobasTaqmanParser): def getAttachmentFileType(self): return "Roche Cobas Taqman 48" diff --git a/bika/lims/exportimport/instruments/rochecobas/taqman/model48_import.pt b/bika/lims/exportimport/instruments/rochecobas/taqman/model48_import.pt index 061acd3ad6..64e0e32177 100644 --- a/bika/lims/exportimport/instruments/rochecobas/taqman/model48_import.pt +++ b/bika/lims/exportimport/instruments/rochecobas/taqman/model48_import.pt @@ -6,6 +6,7 @@  

Advanced options

From fc4e83e990d6b5f4fbee7b1442f8d8678211565b Mon Sep 17 00:00:00 2001 From: Nihadness <1992.nihad@gmail.com> Date: Fri, 16 Mar 2018 11:17:10 +0100 Subject: [PATCH 2/3] Polish. --- .../exportimport/instruments/rochecobas/taqman/model48.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py b/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py index 911b4034d6..17ca1c9f86 100644 --- a/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py +++ b/bika/lims/exportimport/instruments/rochecobas/taqman/model48.py @@ -29,13 +29,11 @@ def __init__(self, rsf, fileformat=None): self._rownum = None self._end_header = False self._fileformat = fileformat + self._separator = ',' if self._fileformat == 'csv' else '\t' def _parseline(self, line): - if self._fileformat == "csv": - sline = line.replace('"', '').split(',') - else: - sline = line.replace('"', '').split('\t') + sline = line.replace('"', '').split(self._separator) if len(sline) > 0 and not self._end_header: self._columns = sline From a8f3d126fb2ef33c844be859e7e2d4b3f23b9400 Mon Sep 17 00:00:00 2001 From: Nihadness <1992.nihad@gmail.com> Date: Mon, 19 Mar 2018 10:49:13 +0100 Subject: [PATCH 3/3] Changes.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 858fa23f09..40f3d42b28 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Changelog **Added** +- #741 CSV Importer for 'Cobas Taqman 48' Instrument Interface - #694 Added "Warn Min" and "Warn Max" subfields in Analysis Specifications - #710 Added more builtin functions for Calculations