Spaces:
Runtime error
Runtime error
ugmSorcero
commited on
Commit
•
753ae25
1
Parent(s):
4107940
Fixes linting
Browse files- interface/utils.py +4 -5
interface/utils.py
CHANGED
@@ -52,22 +52,22 @@ def extract_text_from_file(file):
|
|
52 |
file_text = all_text
|
53 |
|
54 |
return file_text
|
55 |
-
|
56 |
# read csv file
|
57 |
elif file.type == "text/csv":
|
58 |
csv = pd.read_csv(file)
|
59 |
# get columns of type string
|
60 |
-
string_columns = csv.select_dtypes(include=[
|
61 |
# get data from columns and join it together
|
62 |
file_text = ""
|
63 |
for row in csv[string_columns].values.tolist():
|
64 |
# remove NaNs
|
65 |
-
row = [x for x in row if str(x) !=
|
66 |
for column in row:
|
67 |
txt = ""
|
68 |
if isinstance(column, list):
|
69 |
try:
|
70 |
-
|
71 |
except:
|
72 |
continue
|
73 |
elif isinstance(column, str):
|
@@ -80,4 +80,3 @@ def extract_text_from_file(file):
|
|
80 |
else:
|
81 |
st.warning(f"File type {file.type} not supported")
|
82 |
return None
|
83 |
-
|
|
|
52 |
file_text = all_text
|
53 |
|
54 |
return file_text
|
55 |
+
|
56 |
# read csv file
|
57 |
elif file.type == "text/csv":
|
58 |
csv = pd.read_csv(file)
|
59 |
# get columns of type string
|
60 |
+
string_columns = csv.select_dtypes(include=["object"]).columns
|
61 |
# get data from columns and join it together
|
62 |
file_text = ""
|
63 |
for row in csv[string_columns].values.tolist():
|
64 |
# remove NaNs
|
65 |
+
row = [x for x in row if str(x) != "nan"]
|
66 |
for column in row:
|
67 |
txt = ""
|
68 |
if isinstance(column, list):
|
69 |
try:
|
70 |
+
txt = " ".join(column)
|
71 |
except:
|
72 |
continue
|
73 |
elif isinstance(column, str):
|
|
|
80 |
else:
|
81 |
st.warning(f"File type {file.type} not supported")
|
82 |
return None
|
|