Skip to content

Commit 2018cc6

Browse files
authored
Support unicode for file system neo4j csv loader in py3 (#259)
* Support unicode for file system neo4j csv loader in py3 * Revert "Support unicode for file system neo4j csv loader in py3" This reverts commit 23f3ae9. * Fix py3 loader unicode encoding issue
1 parent d2109ce commit 2018cc6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

databuilder/loader/file_system_neo4j_csv_loader.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,23 @@ def _get_writer(self,
166166
return writer
167167

168168
LOGGER.info('Creating file for {}'.format(key))
169-
file_out = open('{}/{}.csv'.format(dir_path, file_suffix), 'w')
170-
171-
def file_out_close():
172-
# type: () -> None
173-
LOGGER.info('Closing file IO {}'.format(file_out))
174-
file_out.close()
175-
self._closer.register(file_out_close)
176169

177170
if six.PY2:
171+
172+
file_out = open('{}/{}.csv'.format(dir_path, file_suffix), 'w')
178173
writer = csv.DictWriter(file_out, fieldnames=csv_record_dict.keys(),
179174
quoting=csv.QUOTE_NONNUMERIC, encoding='utf-8')
180175
else:
176+
file_out = open('{}/{}.csv'.format(dir_path, file_suffix), 'w', encoding='utf8')
181177
writer = csv.DictWriter(file_out, fieldnames=csv_record_dict.keys(),
182178
quoting=csv.QUOTE_NONNUMERIC)
183179

180+
def file_out_close():
181+
# type: () -> None
182+
LOGGER.info('Closing file IO {}'.format(file_out))
183+
file_out.close()
184+
self._closer.register(file_out_close)
185+
184186
writer.writeheader()
185187
file_mapping[key] = writer
186188

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.11'
5+
__version__ = '2.5.12'
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)