Skip to content

Commit ebc7c3e

Browse files
committed
Don't print label/relation strings as bytes type
1 parent 01eb959 commit ebc7c3e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bulk_insert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def report_completion(self, runtime):
9999
class EntityFile(object):
100100
def __init__(self, filename):
101101
# The label or relation type string is the basename of the file
102-
self.entity_str = os.path.splitext(os.path.basename(filename))[0].encode()
102+
self.entity_str = os.path.splitext(os.path.basename(filename))[0]
103103
# Input file handling
104104
self.infile = io.open(filename, 'rt')
105105
# Initialize CSV reader that ignores leading whitespace in each field
@@ -140,8 +140,9 @@ def reset_partial_binary(self):
140140
def pack_header(self, header):
141141
prop_count = len(header) - self.prop_offset
142142
# String format
143-
fmt = "=%dsI" % (len(self.entity_str) + 1) # Unaligned native, entity_string, count of properties
144-
args = [self.entity_str, prop_count]
143+
entity_bytes = self.entity_str.encode()
144+
fmt = "=%dsI" % (len(entity_bytes) + 1) # Unaligned native, entity name, count of properties
145+
args = [entity_bytes, prop_count]
145146
for p in header[self.prop_offset:]:
146147
prop = p.encode()
147148
fmt += "%ds" % (len(prop) + 1) # encode string with a null terminator

0 commit comments

Comments
 (0)