Reading binary data with the CSV module

MRAB python at mrabarnett.plus.com
Mon Nov 30 12:08:11 EST 2020


On 2020-11-30 03:59, Jason Friedman wrote:
>>
>> csv.DictReader appears to be happy with a list of strings representing
>> the lines.
>>
>> Try this:
>>
>> contents = source_file.content()
>>
>> for row in csv.DictReader(contents.decode('utf-8').splitlines()):
>>      print(row)
>>
> 
> Works great, thank you! Question ... will this form potentially use less
> memory?
> 
> for row in
> csv.DictReader(source_file.content().decode('utf-8').splitlines()):
>      print(row)
> 
Yes, but it won't matter that much unless there's a _lot_ of data.


More information about the Python-list mailing list