Skip to content

Commit

Permalink
csv
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Jun 13, 2024
1 parent 0a88421 commit 8361ba5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions irs_reader/text_format_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ def to_csv(
):
if not vd:
vd = VersionDocumentizer()
stdout = getattr(sys.stdout, "buffer", sys.stdout)

if outfilepath:
stdout = open(outfilepath, "wb") # or 'wb' ?
out_file = open(outfilepath, "w")
else:
out_file = sys.stdout

fieldnames = []
fieldnames = [
"object_id",
"form",
Expand All @@ -65,7 +66,7 @@ def to_csv(
"group_name",
"group_index",
]
writer = csv.DictWriter(stdout, fieldnames=fieldnames, quoting=csv.QUOTE_MINIMAL)
writer = csv.DictWriter(out_file, fieldnames=fieldnames, quoting=csv.QUOTE_MINIMAL)
writer.writeheader() # this fails in python3?
results = parsed_filing.get_result()

Expand Down

0 comments on commit 8361ba5

Please sign in to comment.