@@ -49,32 +49,29 @@ def _json_to_table(json_obj, data_key='data'):
49
49
type_key = 'type' if json_obj ['info' ][0 ].get ('type' ) else 'db_type'
50
50
51
51
# for each item in info, store the type and column name
52
+ # for each item in info, type has to be converted from DB data types (SQL server in most cases)
53
+ # to corresponding numpy type
52
54
for idx , col , col_type , ignore_value in \
53
- [(idx , x ['name' ], x [type_key ], "NULL" ) for idx , x in enumerate (json_obj ['info' ])]:
55
+ [(idx , x ['name' ], x [type_key ]. lower (), None ) for idx , x in enumerate (json_obj ['info' ])]:
54
56
55
- # if default value is NULL, set ignore value to None
56
- if ignore_value == "NULL" :
57
- ignore_value = None
58
57
# making type adjustments
59
- if col_type == "char" or col_type == "STRING" or 'VARCHAR' in col_type or col_type == "NULL" :
58
+ if (col_type == "char" or col_type == "string" or 'varchar' in col_type or col_type == "null" or
59
+ col_type == 'datetime' ):
60
60
col_type = "str"
61
61
ignore_value = "" if (ignore_value is None ) else ignore_value
62
- elif col_type == "boolean" or col_type == "BINARY " :
62
+ elif col_type == "boolean" or col_type == "binary " :
63
63
col_type = "bool"
64
64
elif col_type == "unsignedByte" :
65
65
col_type = np .ubyte
66
- elif (col_type == "int" or col_type == "short" or col_type == "long" or col_type == "NUMBER "
67
- or col_type == 'INTEGER ' ):
66
+ elif (col_type == "int" or col_type == "short" or col_type == "long" or col_type == "number "
67
+ or col_type == 'integer ' ):
68
68
# int arrays do not admit Non/nan vals
69
69
col_type = np .int64
70
70
ignore_value = - 999 if (ignore_value is None ) else ignore_value
71
- elif col_type == "double" or col_type .lower () == "float" or col_type == "DECIMAL " :
71
+ elif col_type == "double" or col_type .lower () == "float" or col_type == "decimal " :
72
72
# int arrays do not admit Non/nan vals
73
73
col_type = np .float64
74
74
ignore_value = - 999 if (ignore_value is None ) else ignore_value
75
- elif col_type == "DATETIME" :
76
- col_type = "str"
77
- ignore_value = "" if (ignore_value is None ) else ignore_value
78
75
79
76
# Make the column list (don't assign final type yet or there will be errors)
80
77
try :
0 commit comments