It is a Dict, keys are never going to be in ordered when you iterate
through them. You need to use an OrderedDict
from collections import OrderedDict
yield OrderedDict({
"count" : self.counter,
"page number" : self.page_num,
"company page url" : response.url,
"company" : name,
"Street" : street,
"zip code" : zipcode,
"city" : city,
"country" : country,
"web" : web
})
On Saturday, August 27, 2016 at 12:02:39 PM UTC-7, Raf Roger wrote:
>
> Hi,
>
> i have a code line as following:
> yield {
> "count" : self.counter,
> "page number" : self.page_num,
> "company page url" : response.url,
> "company" : name,
> "Street" : street,
> "zip code" : zipcode,
> "city" : city,
> "country" : country,
> "web" : web
> }
>
> However in the csv result, fields do not respect this order and therefore
> the "web" field can be as first field in csv export and next can be "zip
> code"
>
> How to force it to have order respected ?
>
> thx.
>
--
You received this message because you are subscribed to the Google Groups
"scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.