logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

21 lines
612 B

import csv
from towhee.operator import PyOperator
class ReadCSV(PyOperator):
"""
Wrapper of python csv: https://docs.python.org/3.8/library/csv.html
"""
def __init__(self, f_path: str, newline='', dialect='excel', **fmtparams):
self._f_path = f_path
self._newline = newline
self._dialect = dialect
self._fmtparams = fmtparams
def __call__(self):
with open(self._f_path, newline=self._newline) as f:
reader = csv.reader(f, self._dialect, **self._fmtparams)
# skip header
next(reader)
yield from reader