[英]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?有没有办法使用 -o 参数指定 CSV 输出中列的顺序?
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.它似乎遵循随机顺序,并且不遵循 items.py 文件中的顺序,或者当项目字段在抓取中填充时。
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.有一个相关的field_to_export
属性在CsvItemExporter
,但是,据我了解,没有办法通过命令行设置。 You need to do it through the pipeline, see:您需要通过管道来完成,请参阅:
您可以通过在 settings.py 中添加一行来解决它
FEED_EXPORT_FIELDS = ['field1', 'field2', 'field3']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.