0

i am developing a spider with several fields with scrapy framework. When I export the scrapped fields to a .csv file, the fields (or columns) are unordered, not as I defined them in items.py file.

Does anyone know how to solve this issue?

Thanks in advance.

José Luis
  • 779
  • 2
  • 6
  • 13
  • Please post your code. – Nick Bailey Apr 01 '15 at 14:34
  • Search for 'scrapy order csv' on this site. This will yield some answers to similar questions that have solutions to your problem. For example: http://stackoverflow.com/questions/6943778/python-scrapy-how-to-get-csvitemexporter-to-write-columns-in-a-specific-order/21204369#21204369 – Frank Martin Apr 02 '15 at 07:11

1 Answers1

0
class myspider(BaseSpider):
    filehandle1 = open('file.xls','w')
    ---------------
    def parse(self, response):
            -----------
            self.filehandle2.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"%(item['a'],item['h'],item['g'],item['f'],item['e'],item['d'],item['c'],item['b']))        
Anandhakumar R
  • 371
  • 1
  • 3
  • 17