Skip to content

Commit

Permalink
Fix encoding issue for publisher (#260)
Browse files Browse the repository at this point in the history
* Fix encoding issue for publisher

* per pr feedback
  • Loading branch information
feng-tao committed May 11, 2020
1 parent 2018cc6 commit f4daa67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions databuilder/publisher/neo4j_csv_publisher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import csv
import ctypes
from io import open
import logging
import time
from os import listdir
Expand Down Expand Up @@ -222,7 +223,7 @@ def _create_indices(self, node_file):
# type: (str) -> None
LOGGER.info('Creating indices. (Existing indices will be ignored)')

with open(node_file, 'r') as node_csv:
with open(node_file, 'r', encoding='utf8') as node_csv:
for node_record in csv.DictReader(node_csv):
label = node_record[NODE_LABEL_KEY]
if label not in self.labels:
Expand Down Expand Up @@ -250,7 +251,7 @@ def _publish_node(self, node_file, tx):
:return:
"""

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

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

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

with open(relation_file, 'r') as relation_csv:
with open(relation_file, 'r', encoding='utf8') as relation_csv:
for count, rel_record in enumerate(csv.DictReader(relation_csv)):
stmt = self.create_relationship_merge_statement(rel_record=rel_record)
tx = self._execute_statement(stmt, tx,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages


__version__ = '2.5.12'
__version__ = '2.5.13'

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

0 comments on commit f4daa67

Please sign in to comment.