Spaces:
Running
Running
Update pages/0 FileChecker.py
Browse files- pages/0 FileChecker.py +18 -1
pages/0 FileChecker.py
CHANGED
|
@@ -97,11 +97,25 @@ def conv_pub(extype):
|
|
| 97 |
keywords = sf.readxml(bytedata)
|
| 98 |
return keywords
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
st.header('File Checker', anchor=False)
|
| 101 |
st.subheader('Put your file here...', anchor=False)
|
| 102 |
|
| 103 |
#===read data===
|
| 104 |
-
uploaded_file = st.file_uploader('', type=['csv','txt','json',
|
| 105 |
|
| 106 |
if uploaded_file is not None:
|
| 107 |
extype = get_ext(uploaded_file)
|
|
@@ -117,6 +131,9 @@ if uploaded_file is not None:
|
|
| 117 |
elif extype.endswith('.tar.gz') or extype.endswith('.xml'):
|
| 118 |
data = conv_pub(uploaded_file)
|
| 119 |
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
col1, col2, col3 = st.columns(3)
|
| 122 |
|
|
|
|
| 97 |
keywords = sf.readxml(bytedata)
|
| 98 |
return keywords
|
| 99 |
|
| 100 |
+
@st.cache_data(ttl=3600)
|
| 101 |
+
def readxls(file):
|
| 102 |
+
papers = pd.read_excel(uploaded_file, sheet_name=0, engine='openpyxl')
|
| 103 |
+
if "About the data" in papers.columns[0]:
|
| 104 |
+
papers = sf.dim(papers)
|
| 105 |
+
col_dict = {'MeSH terms': 'Keywords',
|
| 106 |
+
'PubYear': 'Year',
|
| 107 |
+
'Times cited': 'Cited by',
|
| 108 |
+
'Publication Type': 'Document Type'
|
| 109 |
+
}
|
| 110 |
+
papers.rename(columns=col_dict, inplace=True)
|
| 111 |
+
|
| 112 |
+
return papers
|
| 113 |
+
|
| 114 |
st.header('File Checker', anchor=False)
|
| 115 |
st.subheader('Put your file here...', anchor=False)
|
| 116 |
|
| 117 |
#===read data===
|
| 118 |
+
uploaded_file = st.file_uploader('', type=['csv', 'txt','json','tar.gz','xml','xls', 'xlsx'], on_change=reset_data)
|
| 119 |
|
| 120 |
if uploaded_file is not None:
|
| 121 |
extype = get_ext(uploaded_file)
|
|
|
|
| 131 |
elif extype.endswith('.tar.gz') or extype.endswith('.xml'):
|
| 132 |
data = conv_pub(uploaded_file)
|
| 133 |
|
| 134 |
+
elif extype.endswith(('.xls', '.xlsx')):
|
| 135 |
+
papers = readxls(uploaded_file)
|
| 136 |
+
|
| 137 |
|
| 138 |
col1, col2, col3 = st.columns(3)
|
| 139 |
|