Add attribute sort helper function
This commit is contained in:
@@ -1643,8 +1643,7 @@ class Export(object):
|
||||
|
||||
if self.file_format == 'csv':
|
||||
csv_data = helpers.flatten_dict(result)
|
||||
csv_headers = [field.split('.') for field in set().union(*csv_data)]
|
||||
csv_headers = ['.'.join(field) for field in sorted(csv_headers, key=lambda s: (len(s), s))]
|
||||
csv_headers = sorted(set().union(*csv_data), key=helpers.sort_attrs)
|
||||
with open(filepath, 'w', encoding='utf-8', newline='') as outfile:
|
||||
writer = csv.DictWriter(outfile, csv_headers)
|
||||
writer.writeheader()
|
||||
|
Reference in New Issue
Block a user