Is there an alternative to using the csv
module to read a csv file in python3 in a streaming way? Currently my data looks something like this:
"field1"::"field2"::"field3"\x02\n
"1"::"hi\n"::"3"\x02\n
"8"::"ok"::"3"\x02\n
The separator is two characters, ::
(the csv
module only accepts a single character separator) and the line separator also contains two characters, \x02\n
. Are there any csvreaders that can be used for python in a streaming mode that would be able to support this?
Here is an example of what I'm trying to do:
>>> import csv
>>> s = ''''"field1"::"field2"::"field3"\x02\n\n"1"::"hi\n"::"3"\x02\n\n"8"::"ok"::"3"\x02\n'''
>>> csvreader=csv.reader(s, delimiter='::', lineterminator='\x02\n')
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: "delimiter" must be a 1-character string
Loading pandas just to read this csv seems like overkill x 100, so I'd like to see what other options there are.