@@ -949,25 +949,31 @@ def camel(match):
949
949
950
950
# from fmriprep
951
951
def less_breakable (a_string ):
952
- """ hardens the string to different envs (i.e. case insensitive, no
953
- whitespace, '#' """
952
+ """hardens the string to different envs (i.e. case insensitive, no
953
+ whitespace, '#'"""
954
954
return "" .join (a_string .split ()).strip ("#" )
955
955
956
956
drop_columns = drop_columns or []
957
957
additional_metadata = additional_metadata or {}
958
- tsv_data = pd .read_csv (in_tsv , sep = "\t " )
958
+ try :
959
+ tsv_data = pd .read_csv (in_tsv , "\t " )
960
+ except pd .errors .EmptyDataError :
961
+ tsv_data = pd .DataFrame ()
959
962
for k , v in additional_metadata .items ():
960
963
tsv_data [k ] = [v ] * len (tsv_data .index )
961
964
for col in drop_columns :
962
965
tsv_data .drop (labels = col , axis = "columns" , inplace = True )
963
- tsv_data .set_index (index_column , drop = True , inplace = True )
966
+ if index_column in tsv_data :
967
+ tsv_data .set_index (index_column , drop = True , inplace = True )
964
968
if enforce_case :
965
969
tsv_data .index = [
966
970
re .sub (re_to_snake , snake , less_breakable (i ), 0 ).lower ()
967
971
for i in tsv_data .index
968
972
]
969
973
tsv_data .columns = [
970
- re .sub (re_to_camel , camel , less_breakable (i ).title (), 0 ).replace ("Csf" , "CSF" )
974
+ re .sub (re_to_camel , camel , less_breakable (i ).title (), 0 ).replace (
975
+ "Csf" , "CSF"
976
+ )
971
977
for i in tsv_data .columns
972
978
]
973
979
json_data = tsv_data .to_json (orient = "index" )
0 commit comments