Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Force output key order
Browse files Browse the repository at this point in the history
  • Loading branch information
collina committed May 29, 2016
1 parent e1d8583 commit 341d7ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion telescope/telescope.py
Expand Up @@ -167,12 +167,15 @@ def write_metric_calculations_to_file(data_filepath,
(bool) True if the file was written successfully.
"""
logger = logging.getLogger('telescope')
fieldnames_ordered = metric_calculations[0].keys()
if fieldnames_ordered[0] != 'timestamp':
fieldnames_ordered.reverse()
try:
with open(data_filepath, 'w') as data_file_raw:
if metric_calculations:
data_file_csv = csv.DictWriter(
data_file_raw,
fieldnames=metric_calculations[0].keys(),
fieldnames=fieldnames_ordered,
delimiter=',',
quotechar='"',
quoting=csv.QUOTE_MINIMAL)
Expand Down

0 comments on commit 341d7ce

Please sign in to comment.