Implemented .convert(multi=True) and refactored CLI to use that method, refs #251, #302

This commit is contained in:
Simon Willison 2021-08-01 21:08:40 -07:00
commit 570bee7edd
3 changed files with 90 additions and 125 deletions

View file

@ -31,8 +31,11 @@ def suggest_column_types(records):
for record in records:
for key, value in record.items():
all_column_types.setdefault(key, set()).add(type(value))
column_types = {}
return types_for_column_types(all_column_types)
def types_for_column_types(all_column_types):
column_types = {}
for key, types in all_column_types.items():
# Ignore null values if at least one other type present:
if len(types) > 1: