-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field order doesnt respected #31
Comments
👍 |
# in tablize function
data.header = sorted(headers)
# change above statement to
data.header = headers # this solves half of your problem. the main reason for order not being preserved is def flatten_list(self, l):
flat_list = {}
for index, item in enumerate(l):
index = text_type(index)
flat_item = self.flatten_item(item)
nested_item = self.nest_flat_item(flat_item, index)
flat_list.update(nested_item) # this line causes improper ordering
return flat_list
def flatten_dict(self, d):
flat_dict = {}
for key, item in d.items():
key = text_type(key)
flat_item = self.flatten_item(item)
nested_item = self.nest_flat_item(flat_item, key)
flat_dict.update(nested_item) # this line causes improper ordering
return flat_dict Since dictionary are based on hashMaps , it is unordered. |
👍 Ordering fields is rather important to the output format - CSVs with fields randomly ordered are much less usable than CSVs with specified ordering. |
👍 |
I agree that this would be ideal. It may be as simple as removing the |
I have solved this with the following subclass of
|
For anyone interested I refactored
|
When i have a serializer with a defined field list like this:
I expected the output of csv to be in the same order. But this doesnt happen.
The text was updated successfully, but these errors were encountered: