简体   繁体   中英

CSV Exports - Ordering of columns using scrapy crawl -o output.csv

Is there a way to specify the order of the columns in a CSV output using the -o parameter?

It seems to follow a random order and does not follow the order in the items.py file or when the item fields get populated in the scrape.

Thanks!

There is a relevant field_to_export attribute in CsvItemExporter , but, as far as I understand, there is no way to set it from the command-line. You need to do it through the pipeline, see:

您可以通过在 settings.py 中添加一行来解决它

FEED_EXPORT_FIELDS = ['field1', 'field2', 'field3']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM