10 examples of 'python csv writer append' in Python

Every line of 'python csv writer append' 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
67def write_csv(writer, data):
68 writer.writerow(data)
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

63def writerow(self, row):
64 self.writer.writerow([s.encode("utf-8") for s in row])
65 # Fetch UTF-8 output from the queue ...
66 data = self.queue.getvalue()
67 data = data.decode("utf-8")
68 # ... and reencode it into the target encoding
69 data = self.encoder.encode(data)
70 # write to the target stream
71 self.stream.write(data)
72 # empty queue
73 self.queue.truncate(0)
30def writerow(self, row):
31 # self.writer.writerow([s.encode("utf-8") for s in row])
32 self.writer.writerow([self._encode_item(s) for s in row])
33 # Fetch UTF-8 output from the queue ...
34 data = self.queue.getvalue()
35 data = data.decode("utf-8")
36 # ... and reencode it into the target encoding
37 data = self.encoder.encode(data)
38 # write to the target stream
39 self.stream.write(data)
40 # empty queue
41 self.queue.truncate(0)
92def __init__(self, row_cls, file):
93 self.fields = row_cls._dialect.fields
94 self._writer = csv.writer(file, row_cls._dialect.csv_dialect)
95 self.needs_header_row = row_cls._dialect.has_header_row
129def writerow(self, row):
130 # Convert embedded Mac line endings to unix style line endings so they get quoted
131 row = dict([(k, v.replace('\r', '\n')) if isinstance(v, six.string_types) else (k, v) for k, v in row.items()])
132
133 if self.line_numbers:
134 self._append_line_number(row)
135
136 csv.DictWriter.writerow(self, row)
41def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
42 # Redirect output to a queue
43 self.queue = cStringIO.StringIO()
44 self.writer = csv.writer(self.queue, dialect=dialect, **kwds)
45 self.stream = f
46 self.encoder = codecs.getincrementalencoder(encoding)()
112def write(self, data):
113 # type: (numpy.ndarray) -> None
114 self.__writer_setup(data)
115 converted_data = self.__convert_to_dict(data)
116 self.__write_row(converted_data)
459def __init__(self, writer: object, column_splitter: str = ',', quote: str = '"', columns_number: int = 0):
460 """
461 Initialize CsvWriter.
462
463 :param writer: data writer
464 :type writer: object
465 :param column_splitter: column splitter
466 :type column_splitter: str
467 :param quote: quote symbol
468 :type quote: str
469 :param columns_number: (Optional) a number of columns, that is used for input validation
470 :type columns_number: int
471 """
472 self.writer = writer
473 self.column_splitter = column_splitter
474 self.quote = quote
475 self.columns_number = columns_number
52def writerow(self, row):
53 try:
54 self._writer.writerow(row)
55 except csv.Error as e:
56 raise Error(str(e))
30def __init__(self):
31 self.out = io.StringIO()
32 super(CsvDataMixin, self).__init__()
33 if hasattr(self, "columns"):
34 columns = [self.encode(col) for col in self.columns]
35 self.writer = csv.DictWriter(self.out, columns,
36 quoting=csv.QUOTE_ALL)
37 self.is_dict = True
38 else:
39 self.writer = csv.writer(self.out, quoting=csv.QUOTE_ALL)
40 self.is_dict = False

Related snippets