CsvItemExporter fails on py3
See original GitHub issuefrom scrapy.exporters import CsvItemExporter
with open('temp.csv', 'w') as f:
exporter = CsvItemExporter(f)
exporter.start_exporting()
exporter.export_item({'a': 'b'})
exporter.finish_exporting()
The previous snippet works fine on python 2, however the following error appears when running on python 3:
Traceback (most recent call last):
File "exporter.py", line 5, in <module>
exporter.export_item({'a': 'b'})
File "/Users/eugenio/.../venv/lib/python3.5/site-packages/scrapy/exporters.py", line 206, in export_item
self._write_headers_and_set_fields_to_export(item)
File "/Users/eugenio/.../venv/lib/python3.5/site-packages/scrapy/exporters.py", line 230, in _write_headers_and_set_fields_to_export
self.csv_writer.writerow(row)
TypeError: write() argument must be str, not bytes
Am I missing something? Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
I have a trouble when use scrapy to write item to csv file
I try to write to csv file in Scrapy using CsvItemExporter. ... representation of `text` (bytes in Python 2.x and unicode in Python...
Read more >[Example code]-Error while merging multiple csv with a condition
Requirement: I have 69 csvs. Merge them on the basis of below condition: Condition: If value in cell at header 'col7' = 1,...
Read more >latest PDF - Scrapy Documentation
Scrapy (/skrepa/) is an application framework for crawling web sites and extracting structured data which can be used.
Read more >Release notes — Scrapy 2.5.0 documentation - Read the Docs
The __init__ method of CsvItemExporter now supports an errors parameter to ... Extended use of InterSphinx to link to Python 3 documentation (issue...
Read more >transistor - PyPI
In this case, we are just going to use the built-in CsvItemExporter but we could ... handling failures with automatic retries, and setting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’d be awesome!
Thanks, makes sense now 😄 I’ll make a PR to mention this in the docs, if that’s OK.