MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / csv

Method csv

functional/streams.py:135–161  ·  view source on GitHub ↗

Reads and parses the input of a csv stream or file. csv_file can be a filepath or an object that implements the iterator interface (defines next() or __next__() depending on python version). >>> seq.csv('examples/camping_purchases.csv').take(2) [['1', 'tent

(self, csv_file, dialect="excel", **fmt_params)

Source from the content-addressed store, hash-verified

133 return self(builtins.range(*args)) # pylint: disable=no-member
134
135 def csv(self, csv_file, dialect="excel", **fmt_params):
136 """
137 Reads and parses the input of a csv stream or file.
138
139 csv_file can be a filepath or an object that implements the iterator interface
140 (defines next() or __next__() depending on python version).
141
142 >>> seq.csv('examples/camping_purchases.csv').take(2)
143 [['1', 'tent', '300'], ['2', 'food', '100']]
144
145 :param csv_file: path to file or iterator object
146 :param dialect: dialect of csv, passed to csv.reader
147 :param fmt_params: options passed to csv.reader
148 :return: Sequence wrapping csv file
149 """
150 if isinstance(csv_file, str):
151 file_open = get_read_function(csv_file, self.disable_compression)
152 input_file = file_open(csv_file)
153 elif hasattr(csv_file, "next") or hasattr(csv_file, "__next__"):
154 input_file = csv_file
155 else:
156 raise ValueError(
157 "csv_file must be a file path or implement the iterator interface"
158 )
159
160 csv_input = csvapi.reader(input_file, dialect=dialect, **fmt_params)
161 return self(csv_input).cache(delete_lineage=True)
162
163 def csv_dict_reader(
164 self,

Callers 7

test_csvMethod · 0.80
test_gzip_csvMethod · 0.80
test_bz2_csvMethod · 0.80
test_xz_csvMethod · 0.80
test_to_csvMethod · 0.80
test_to_csv_winMethod · 0.80

Calls 2

get_read_functionFunction · 0.90
cacheMethod · 0.80

Tested by 7

test_csvMethod · 0.64
test_gzip_csvMethod · 0.64
test_bz2_csvMethod · 0.64
test_xz_csvMethod · 0.64
test_to_csvMethod · 0.64
test_to_csv_winMethod · 0.64