Skip to content

Commit

Permalink
Merge pull request #550 from HazyResearch/raphael_pgtsvnull
Browse files Browse the repository at this point in the history
Adds support for null values in int/float columns in pgtsv_to_json; a…
  • Loading branch information
netj authored Jun 27, 2016
2 parents e7d4711 + f3db294 commit 6d29bd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion database/pgtsv_to_json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def convert_type_func(ty, ty_rest = ""):
else:
def convert_other_array(value):
arr = csv.reader([value[1:-1]], delimiter=',', quotechar='"').next()
return map(convert, arr)
convert_or_null = lambda x: None if x == 'NULL' else convert(x)
return map(convert_or_null, arr)
return convert_other_array
else: # non-array, must be primitive type
normalized_type_name = {
Expand All @@ -57,6 +58,8 @@ def convert_type_func(ty, ty_rest = ""):
"bigint" : "int",
"double" : "float",
"numeric" : "float",
"real" : "float",
"double precision" : "float",
"unknown" : "text",
}
convert_for_primitive_types = {
Expand Down

0 comments on commit 6d29bd9

Please sign in to comment.