Skip to content

Commit

Permalink
Merge pull request #165 from will-moore/batch_roi_export_csv_unicode
Browse files Browse the repository at this point in the history
batch ROI export CSV unicode
  • Loading branch information
jburel authored Jan 9, 2020
2 parents ec5582d + e0b4afa commit b68b841
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions omero/export_scripts/Batch_ROI_Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,14 @@ def write_csv(conn, export_data, script_params, units_symbol):
units_symbol = "pixels"
csv_header = csv_header.replace(",length,", ",length (%s)," % units_symbol)
csv_header = csv_header.replace(",area,", ",area (%s)," % units_symbol)
csv_rows = [csv_header.encode('utf-8')]
csv_rows = [csv_header]

for row in export_data:
# cells = [("%s" % row.get(name, "")) for name in COLUMN_NAMES]
cells = []
for name in COLUMN_NAMES:
td = row.get(name, '')
cells.append(str(td).encode('utf-8'))
csv_rows.append(b",".join(cells))

with open(file_name, 'wb') as csv_file:
csv_file.write(b"\n".join(csv_rows))
cells = [str(row.get(name, "")) for name in COLUMN_NAMES]
csv_rows.append(",".join(cells))

with open(file_name, 'w') as csv_file:
csv_file.write("\n".join(csv_rows))

return conn.createFileAnnfromLocalFile(file_name, mimetype="text/csv")

Expand Down

0 comments on commit b68b841

Please sign in to comment.