Skip to content

Commit

Permalink
Utilize max() to fetch most field names for CLI CSV output header (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
BroderPeters authored Dec 24, 2024
1 parent 86b2775 commit 3ed3b16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dkb_robo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _load_format(output_format):
def formatter(data): # pragma: no cover
if len(data) == 0:
return
writer = csv.DictWriter(sys.stdout, fieldnames=data[0].keys(), restval="", extrasaction="ignore")
writer = csv.DictWriter(sys.stdout, fieldnames=max(data, key=len).keys())
writer.writeheader()
writer.writerows(data)

Expand Down

0 comments on commit 3ed3b16

Please sign in to comment.