Exporting Scrapy items to a .csv file keeps crawl output easy to review in spreadsheet tools, compare between runs, or hand off to other systems without an extra conversion step.
Scrapy writes CSV output through its feed export system while a spider runs. Using -O with scrapy crawl writes a feed file immediately, and a target name ending in .csv selects the built-in CsvItemExporter so the file is saved with a header row followed by one row per yielded item.
CSV keeps a fixed column layout, so field order should be set before long crawls and nested values still end up serialized as plain text inside a cell. The overwrite mode used below replaces any existing file with the same name, and leaving the header implicit makes the first exported item decide the initial column order instead of a deliberate schema.
Related: How to export Scrapy items to JSON
Related: How to enable item pipelines in Scrapy
Steps to export Scrapy items to CSV:
- Open a terminal in the Scrapy project directory.
$ cd /srv/catalog_demo
Run the command from the directory that contains scrapy.cfg so the project settings and spider names resolve correctly.
- Set FEED_EXPORT_FIELDS and FEED_EXPORT_ENCODING in settings.py to lock the CSV header order and write UTF-8 output.
FEED_EXPORT_FIELDS = [ "name", "price", "url", ] FEED_EXPORT_ENCODING = "utf-8"
If FEED_EXPORT_FIELDS is omitted, the CSV header is inferred from the first exported item instead.
Use utf-8-sig instead of utf-8 when spreadsheet software on Windows opens UTF-8 text with garbled non-ASCII characters.
- Run the spider with the CSV export target.
$ scrapy crawl catalog -O products.csv ##### snipped ##### 2026-04-16 05:32:17 [scrapy.extensions.feedexport] INFO: Stored csv feed (3 items) in: products.csv
The file extension selects the exporter, so products.csv uses the built-in CSV feed exporter automatically.
-O overwrites any existing products.csv in place.
- Read the saved file to confirm the header row and exported items.
$ cat products.csv name,price,url Starter Plan,$29,https://shop.example.com/products/starter-plan.html Team Plan,$79,https://shop.example.com/products/team-plan.html Growth Plan,$129,https://shop.example.com/products/growth-plan.html
The header should follow FEED_EXPORT_FIELDS exactly, and missing item fields are written as empty cells.
- Compare the file line total with the exported item count when a quick verification is needed.
$ wc -l products.csv 4 products.csvThe total includes the header row, so 4 lines means the file contains 3 exported items.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
