17

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!

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Eric Valente
  • 439
  • 7
  • 14

2 Answers2

10

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:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
8

You can solve it from adding a line in settings.py

FEED_EXPORT_FIELDS = ['field1', 'field2', 'field3']
ndrwnaguib
  • 5,623
  • 3
  • 28
  • 51
Md. Sazol
  • 81
  • 1
  • 3