@@ -65,6 +65,11 @@ def typed_prop_to_binary(prop_val, prop_type):
6565 # Remove leading and trailing whitespace
6666 prop_val = prop_val .strip ()
6767
68+ if prop_val == "" :
69+ # An empty string indicates a NULL property.
70+ # TODO This is not allowed in Cypher, consider how to handle it here rather than in-module.
71+ return struct .pack (format_str , 0 )
72+
6873 # TODO allow ID type specification
6974 if prop_type == Type .LONG :
7075 try :
@@ -107,7 +112,7 @@ def typed_prop_to_binary(prop_val, prop_type):
107112 return array_prop_to_binary (format_str , prop_val )
108113
109114 # If it hasn't returned by this point, it is trying to set it to a type that it can't adopt
110- raise Exception ("unable to parse [" + prop_val + "] with type [" + repr (prop_type )+ "]" )
115+ raise SchemaError ("unable to parse [" + prop_val + "] with type [" + repr (prop_type )+ "]" )
111116
112117
113118# Convert a single CSV property field with an inferred type into a binary stream.
@@ -227,14 +232,14 @@ def convert_header_with_schema(self, header):
227232 # Multiple colons found in column name, emit error.
228233 # TODO might need to check for backtick escapes
229234 if len (pair ) > 2 :
230- raise CSVError ("Field '%s' had %d colons" % field , len (field ))
235+ raise CSVError ("%s: Field '%s' had %d colons" % ( self . infile . name , field , len (field ) ))
231236
232237 # Convert the column type.
233238 col_type = convert_schema_type (pair [1 ].upper ().strip ())
234239
235240 # If the column did not have a name but the type requires one, emit an error.
236241 if len (pair [0 ]) == 0 and col_type not in (Type .ID , Type .START_ID , Type .END_ID , Type .IGNORE ):
237- raise SchemaError ("Each property in the header should be a colon-separated pair" )
242+ raise SchemaError ("%s: Each property in the header should be a colon-separated pair" % ( self . infile . name ) )
238243 else :
239244 # We have a column name and a type.
240245 # Only store the name if the column's values should be added as properties.
0 commit comments