Skip to content

Commit

Permalink
fix(cli): bytes encoding;
Browse files Browse the repository at this point in the history
- Encode bytes for csv writer.
  • Loading branch information
JVickery-TBS committed Jan 8, 2024
1 parent 2b4cc80 commit 77bd30d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckanext/recombinant/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def _write_one_csv(lc, pkgs, chromo, outfile):
column_ids = [f['datastore_id'] for f in chromo['fields']
] + chromo.get('csv_org_extras', []) + [
'owner_org', 'owner_org_title']
out.writerow(column_ids)
out.writerow([id.encode('utf-8') for id in column_ids])

for pkg in pkgs:
for res in pkg['resources']:
Expand Down Expand Up @@ -561,7 +561,7 @@ def _write_one_csv(lc, pkgs, chromo, outfile):
u','.join(record[col]) if isinstance(record[col], list) else
record[col]
).encode('utf-8') for col in column_ids]
out.writerow(['\r\n'.join(col.splitlines()) for col in row])
out.writerow(['\r\n'.join(col.splitlines()).encode('utf-8') for col in row])
except KeyError:
click.echo('resource {0} table missing keys for {1}'.format(
chromo['resource_name'], pkg['owner_org']))
Expand Down

0 comments on commit 77bd30d

Please sign in to comment.