Skip to content

Commit a06600f

Browse files
committed
Export errors due to utf-8 characters
1 parent 7811aea commit a06600f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

octoprint_printhistory/export.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def exportHistoryData(self, exportType):
88
import flask
9-
import csv
9+
import unicodecsv as csv
1010
import StringIO
1111
import re
1212
from utils import namedtuple_with_defaults, prepare_dict, load_json, rename_duplicates
@@ -19,7 +19,7 @@ def exportHistoryData(self, exportType):
1919
headers = ['File name', 'Timestamp', 'Success', 'Print time', 'Filament length', 'Filament volume']
2020
fields = ['fileName', 'timestamp', 'success', 'printTime', 'filamentLength', 'filamentVolume']
2121
if exportType == 'csv':
22-
writer = csv.writer(si, quoting=csv.QUOTE_ALL)
22+
writer = csv.writer(si, quoting=csv.QUOTE_ALL, encoding='utf-8')
2323
writer.writerow(headers)
2424

2525
for historyDetails in history_dict:
@@ -50,7 +50,7 @@ def exportHistoryData(self, exportType):
5050
csv_header = rearranged_header
5151

5252
ParametersRow = namedtuple_with_defaults('TableRow', csv_header)
53-
writer = csv.writer(si, quoting=csv.QUOTE_ALL)
53+
writer = csv.writer(si, quoting=csv.QUOTE_ALL, encoding='utf-8')
5454
writer.writerow(csv_header)
5555
for historyDetails in history_dict:
5656
parameters = load_json(historyDetails, "parameters")

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
OctoPrint
2-
XlsxWriter
2+
XlsxWriter
3+
unicodecsv

0 commit comments

Comments
 (0)