File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,7 @@ def tsv_to_json_pandas(tsv_string, project_id):
565565
566566 field_type = field_schema .get ("type" )
567567 split_regex = field_schema .get ("x-split-regex" )
568+ field_format = field_schema .get ("format" )
568569
569570 # Handle arrays
570571 if field_type == "array" :
@@ -574,13 +575,12 @@ def tsv_to_json_pandas(tsv_string, project_id):
574575 elif field_type == "number" :
575576 df [column ] = df [column ].apply (lambda x : convert_to_number (x ))
576577
577- # Handle dates (string with format date)
578- elif field_type == "string" and field_schema . get ( "format" ) == "date" :
579- df [column ] = df [column ].apply (lambda x : x if x and x .strip () else None )
578+ # Handle dates (string with format date): set None if missing/empty/NaN
579+ elif field_type == "string" and field_format == "date" :
580+ df [column ] = df [column ].apply (lambda x : x if ( x is not None and isinstance ( x , str ) and x .strip () ) else None )
580581
581- # Handle strings
582+ # Handle strings (not date): always use empty string for missing/None/NaN
582583 elif field_type == "string" :
583- # For string fields, always use empty string for missing/None/NaN
584584 df [column ] = df [column ].apply (lambda x : x if (x is not None and not (isinstance (x , float ) and pd .isna (x ))) else "" )
585585
586586 # Other types: leave as is
You can’t perform that action at this time.
0 commit comments