Skip to content

Commit f4daa67

Browse files
authored
Fix encoding issue for publisher (#260)
* Fix encoding issue for publisher * per pr feedback
1 parent 2018cc6 commit f4daa67

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

databuilder/publisher/neo4j_csv_publisher.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
import csv
33
import ctypes
4+
from io import open
45
import logging
56
import time
67
from os import listdir
@@ -222,7 +223,7 @@ def _create_indices(self, node_file):
222223
# type: (str) -> None
223224
LOGGER.info('Creating indices. (Existing indices will be ignored)')
224225

225-
with open(node_file, 'r') as node_csv:
226+
with open(node_file, 'r', encoding='utf8') as node_csv:
226227
for node_record in csv.DictReader(node_csv):
227228
label = node_record[NODE_LABEL_KEY]
228229
if label not in self.labels:
@@ -250,7 +251,7 @@ def _publish_node(self, node_file, tx):
250251
:return:
251252
"""
252253

253-
with open(node_file, 'r') as node_csv:
254+
with open(node_file, 'r', encoding='utf8') as node_csv:
254255
for count, node_record in enumerate(csv.DictReader(node_csv)):
255256
stmt = self.create_node_merge_statement(node_record=node_record)
256257
tx = self._execute_statement(stmt, tx)
@@ -306,7 +307,7 @@ def _publish_relation(self, relation_file, tx):
306307
LOGGER.info('Pre-processing relation with {}'.format(self._relation_preprocessor))
307308

308309
count = 0
309-
with open(relation_file, 'r') as relation_csv:
310+
with open(relation_file, 'r', encoding='utf8') as relation_csv:
310311
for rel_record in csv.DictReader(relation_csv):
311312
stmt, params = self._relation_preprocessor.preprocess_cypher(
312313
start_label=rel_record[RELATION_START_LABEL],
@@ -322,7 +323,7 @@ def _publish_relation(self, relation_file, tx):
322323

323324
LOGGER.info('Executed pre-processing Cypher statement {} times'.format(count))
324325

325-
with open(relation_file, 'r') as relation_csv:
326+
with open(relation_file, 'r', encoding='utf8') as relation_csv:
326327
for count, rel_record in enumerate(csv.DictReader(relation_csv)):
327328
stmt = self.create_relationship_merge_statement(rel_record=rel_record)
328329
tx = self._execute_statement(stmt, tx,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import setup, find_packages
33

44

5-
__version__ = '2.5.12'
5+
__version__ = '2.5.13'
66

77
requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'requirements.txt')
88
with open(requirements_path) as requirements_file:

0 commit comments

Comments
 (0)