10 examples of 'python csv reader' in Python

Every line of 'python csv reader' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
22def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
23 self.reader = csv.reader(f, dialect=dialect, **kwds)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

136def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
137 """ csv.py doesn't do Unicode; encode temporarily as UTF-8."""
138 csv_reader = csv.reader(utf_8_encoder(unicode_csv_data),
139 dialect=dialect, **kwargs)
140 for row in csv_reader:
141 # decode UTF-8 back to Unicode, cell by cell:
142 yield [unicode(cell, 'utf-8') for cell in row]
3def reader():
4 with open('output.cvs', 'rb') as out:
5 reader = csv.reader(out, delimiter=',', quotechar='"')
6 for line in reader:
7 yield line
35def __init__(self, f, dialect=None, encoding='utf-8', errors='strict',
36 **kwds):
37 format_params = ['delimiter', 'doublequote', 'escapechar', 'lineterminator',
38 'quotechar', 'quoting', 'skipinitialspace']
39 if dialect is None:
40 if not any([kwd_name in format_params for kwd_name in kwds.keys()]):
41 dialect = csv.excel
42 self.reader = csv.reader(f, dialect, **kwds)
43 self.encoding = encoding
44 self.encoding_errors = errors
194def __init__(self, f, dialect=csv.excel, encoding='utf-8', **kwds):
195 f = UTF8Recoder(f, encoding)
196 self.reader = csv.reader(f, dialect=dialect, **kwds)
144def __init__(self, f, encoding=None, errors='strict', **csvargs):
145 f = UTF8Recoder(f, encoding=encoding, errors=errors)
146 self.reader = csv.reader(f, **csvargs)
22def _unicode_csv_dict_reader(unicode_csv_data, fieldnames=None, **kwargs):
23 if fieldnames:
24 fieldnames = [val.encode('utf-8') for val in fieldnames]
25 csv_reader = csv.DictReader(unicode_csv_data,
26 fieldnames=fieldnames, **kwargs)
27 for row in csv_reader:
28 # decode UTF-8 back to Unicode, cell by cell:
29 yield {unicode(key, 'utf-8'): unicode(value, 'utf-8') for key, value in row.items()}
157def __init__(self, f, encoding="utf-8", **kwds):
158 self.encoding = encoding
159 self.reader = csv.DictReader(f, **kwds)
252@staticmethod
253def _createCsvReader(fileObj):
254 # We'll be operating on csvs with arbitrarily long fields
255 csv.field_size_limit(2**27)
256
257 # Make sure readline() works on windows too
258 os.linesep = "\n"
259
260 return csv.reader(fileObj, dialect="excel")
116def next(self):
117 row = self.reader.next()
118 encoding = self.encoding
119 encoding_errors = self.encoding_errors
120 unicode_ = unicode
121 if self._parse_numerics:
122 float_ = float
123 return [(value if isinstance(value, float_) else
124 unicode_(value, encoding, encoding_errors))
125 for value in row]
126 else:
127 return [unicode_(value, encoding, encoding_errors)
128 for value in row]

Related snippets