Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AmendsenProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shaik Janipasha
AmendsenProject
Commits
f4daa679
Unverified
Commit
f4daa679
authored
May 11, 2020
by
Tao Feng
Committed by
GitHub
May 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix encoding issue for publisher (#260)
* Fix encoding issue for publisher * per pr feedback
parent
2018cc66
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
neo4j_csv_publisher.py
databuilder/publisher/neo4j_csv_publisher.py
+5
-4
setup.py
setup.py
+1
-1
No files found.
databuilder/publisher/neo4j_csv_publisher.py
View file @
f4daa679
import
copy
import
copy
import
csv
import
csv
import
ctypes
import
ctypes
from
io
import
open
import
logging
import
logging
import
time
import
time
from
os
import
listdir
from
os
import
listdir
...
@@ -222,7 +223,7 @@ class Neo4jCsvPublisher(Publisher):
...
@@ -222,7 +223,7 @@ class Neo4jCsvPublisher(Publisher):
# type: (str) -> None
# type: (str) -> None
LOGGER
.
info
(
'Creating indices. (Existing indices will be ignored)'
)
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
):
for
node_record
in
csv
.
DictReader
(
node_csv
):
label
=
node_record
[
NODE_LABEL_KEY
]
label
=
node_record
[
NODE_LABEL_KEY
]
if
label
not
in
self
.
labels
:
if
label
not
in
self
.
labels
:
...
@@ -250,7 +251,7 @@ class Neo4jCsvPublisher(Publisher):
...
@@ -250,7 +251,7 @@ class Neo4jCsvPublisher(Publisher):
:return:
: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
)):
for
count
,
node_record
in
enumerate
(
csv
.
DictReader
(
node_csv
)):
stmt
=
self
.
create_node_merge_statement
(
node_record
=
node_record
)
stmt
=
self
.
create_node_merge_statement
(
node_record
=
node_record
)
tx
=
self
.
_execute_statement
(
stmt
,
tx
)
tx
=
self
.
_execute_statement
(
stmt
,
tx
)
...
@@ -306,7 +307,7 @@ class Neo4jCsvPublisher(Publisher):
...
@@ -306,7 +307,7 @@ class Neo4jCsvPublisher(Publisher):
LOGGER
.
info
(
'Pre-processing relation with {}'
.
format
(
self
.
_relation_preprocessor
))
LOGGER
.
info
(
'Pre-processing relation with {}'
.
format
(
self
.
_relation_preprocessor
))
count
=
0
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
):
for
rel_record
in
csv
.
DictReader
(
relation_csv
):
stmt
,
params
=
self
.
_relation_preprocessor
.
preprocess_cypher
(
stmt
,
params
=
self
.
_relation_preprocessor
.
preprocess_cypher
(
start_label
=
rel_record
[
RELATION_START_LABEL
],
start_label
=
rel_record
[
RELATION_START_LABEL
],
...
@@ -322,7 +323,7 @@ class Neo4jCsvPublisher(Publisher):
...
@@ -322,7 +323,7 @@ class Neo4jCsvPublisher(Publisher):
LOGGER
.
info
(
'Executed pre-processing Cypher statement {} times'
.
format
(
count
))
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
)):
for
count
,
rel_record
in
enumerate
(
csv
.
DictReader
(
relation_csv
)):
stmt
=
self
.
create_relationship_merge_statement
(
rel_record
=
rel_record
)
stmt
=
self
.
create_relationship_merge_statement
(
rel_record
=
rel_record
)
tx
=
self
.
_execute_statement
(
stmt
,
tx
,
tx
=
self
.
_execute_statement
(
stmt
,
tx
,
...
...
setup.py
View file @
f4daa679
...
@@ -2,7 +2,7 @@ import os
...
@@ -2,7 +2,7 @@ import os
from
setuptools
import
setup
,
find_packages
from
setuptools
import
setup
,
find_packages
__version__
=
'2.5.1
2
'
__version__
=
'2.5.1
3
'
requirements_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'requirements.txt'
)
requirements_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'requirements.txt'
)
with
open
(
requirements_path
)
as
requirements_file
:
with
open
(
requirements_path
)
as
requirements_file
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment