Ejemplo n.º 1
0
 def __init__(self, file: str = "", *, dir: str = ""):
     """
     Args:
         file: name of hdf5 file
     """
     self.filepath = DPath.from_path(file).prepend_path(
         DPath.from_path(dir, dir=True))
Ejemplo n.º 2
0
 def __init__(self, file: str = "", dir: str = "", format: str = "csv"):
     """
     Args:
         file:  name of file to which the dataframe is stored
         (in native pandas pickle format), if it is None the dataframe is returned by apply
         method as main result (i.e operator is final consumer in pipeline)
     """
     self.filepath = DPath.from_path(file).prepend_path(
         DPath.from_path(dir, dir=True))
     assert format in ["csv", "xlsx"], "Unsupported format"
     self.format = format
Ejemplo n.º 3
0
    def __init__(self, filename: str, *, dir: str = "", shortname = None, channels = None):
        self._filepath = DPath.from_path(filename).prepend_path(DPath.from_path(dir, dir=True))

        with open(str(self._filepath), "rt", encoding="utf-16le") as f:
            longline = None
            cline = False
            data = defaultdict(list)
            gsize = 0
            channel = 0
            for line in f:
                line = line.rstrip()
                if cline:
                    longline += line.rstrip("/")
                else:
                    longline = line.rstrip("/")
                if line.endswith("/"):
                    longline += ","
                    cline = True
                    continue
                else:
                    cline = False

                m = match(r"Sampling Frequency\(kHz\)=(\d+,\d+)", longline)
                if m:
                    self.fs = 1000 * float(m.group(1).replace(",","."))
                    continue

                m = match(r"Channel\s+Number=(\d+)", longline)
                if m:
                    channel = int(m.group(1))-1
                    continue

                m = match(r"(?:Sweep|LivePlay)\s+Data\(mV\)<(\d+)>=(.*)", longline)
                if m:
                    gsize += int(m.group(1))
                    dataline = m.group(2)
                    for subm in finditer(r"(-?)(\d+),(\d+),?", dataline):
                        value = int(subm.group(2)) + int(subm.group(3)) / 100
                        if subm.group(1) == "-":
                            value = -value
                        data[channel].append(value)
        self.data = data
        self.channels = channels

        if shortname is None:
            self.shortpath = self._filepath
        elif isinstance(shortname, Pattern):
            stem = self._filepath.stem
            m = shortname.search(stem)
            if m:
                stem = m.group(0)
            self.shortpath = self._filepath.restem(stem)
Ejemplo n.º 4
0
 def __init__(self,
              file: str = "",
              *,
              dir: str = "",
              dialect="excel",
              time_unit: TimeUnit = TimeUnit.SECOND,
              gzipped=False):
     """
     Args:
         file: name of CSV file
     """
     self.filepath = DPath.from_path(file).prepend_path(
         DPath.from_path(dir, dir=True))
     if gzipped:
         self.filepath.add_suffix(".gz")
     self.dialect = dialect
     self.time_unit = time_unit
     self.gzipped = gzipped
Ejemplo n.º 5
0
    def __init__(self,
                 filename: str,
                 *,
                 dir: str = "",
                 shortname=None,
                 channels=None):
        self._filepath = DPath.from_path(filename).prepend_path(
            DPath.from_path(dir, dir=True))
        self.channels = channels

        if shortname is None:
            self.shortpath = self._filepath
        elif isinstance(shortname, Pattern):
            stem = self._filepath.stem
            m = shortname.search(stem)
            if m:
                stem = m.group(0)
            self.shortpath = self._filepath.restem(stem)
Ejemplo n.º 6
0
 def __init__(self,
              filename: str,
              fs,
              *,
              dir: str = "",
              dialect: str = "excel",
              header: bool = True,
              default_unit: str = "unit",
              transpose: bool = False,
              annotation: Union[str, Sequence[str]] = None):
     self._filepath = DPath.from_path(filename).prepend_path(
         DPath.from_path(dir, dir=True))
     self.dialect = dialect
     self.header = header
     self.default_unit = default_unit
     self.fs = fs
     self.transpose = transpose
     self.annotation = annotation