Skip to content
Snippets Groups Projects
Commit b959fb50 authored by Nicolas Barthes's avatar Nicolas Barthes
Browse files

correction for CSV import yfile (autodetection of delimiter and samples name)

parent b3239243
No related branches found
No related tags found
No related merge requests found
...@@ -60,8 +60,10 @@ if file == files_format[0]: ...@@ -60,8 +60,10 @@ if file == files_format[0]:
ycal_csv = M00.file_uploader("Select corresponding Chemical Data", type="csv", help=" :mushroom: select a csv matrix with samples as rows and chemical values as a column") ycal_csv = M00.file_uploader("Select corresponding Chemical Data", type="csv", help=" :mushroom: select a csv matrix with samples as rows and chemical values as a column")
if ycal_csv: if ycal_csv:
sepy = M00.radio("separator (Y file): ", options=[";", ","], key=2) sepy = M00.radio("Select separator (Y file) - _detected_: " + str(find_delimiter('data/'+ycal_csv.name)),
hdry = M00.radio("samples name (Y file)?: ", options=["no", "yes"], key=3) options=[";", ","], index=[";", ","].index(str(find_delimiter('data/'+ycal_csv.name))), key=2)
hdry = M00.radio("samples name (Y file)? - _detected_: " + str(find_col_index('data/'+ycal_csv.name)),
options=["no", "yes"], index=["no", "yes"].index(str(find_col_index('data/'+ycal_csv.name))), key=3)
if hdry == "yes": col = 0 if hdry == "yes": col = 0
else: col = False else: col = False
else: else:
...@@ -71,15 +73,14 @@ if file == files_format[0]: ...@@ -71,15 +73,14 @@ if file == files_format[0]:
file_name = str(xcal_csv.name) +' and '+ str(ycal_csv.name) file_name = str(xcal_csv.name) +' and '+ str(ycal_csv.name)
xfile = pd.read_csv(xcal_csv, decimal='.', sep=sepx, index_col=col, header=0) xfile = pd.read_csv(xcal_csv, decimal='.', sep=sepx, index_col=col, header=0)
yfile = pd.read_csv(ycal_csv, decimal='.', sep=sepy, index_col=col) yfile = pd.read_csv(ycal_csv, decimal='.', sep=sepy, index_col=col)
if yfile.shape[1]>0 and xfile.shape[1]>0 : if yfile.shape[1]>0 and xfile.shape[1]>0 :
spectra, meta_data = col_cat(xfile) spectra, meta_data = col_cat(xfile)
y, idx = col_cat(yfile) chem_data, idx = col_cat(yfile)
if y.shape[1]>1: if chem_data.shape[1]>1:
yname = M00.selectbox('Select target', options=y.columns) yname = M00.selectbox('Select target', options=chem_data.columns)
y = y.loc[:,yname] y = chem_data.loc[:,yname]
else: else:
y = y.iloc[:,0] y = chem_data.iloc[:,0]
spectra = pd.DataFrame(spectra).astype(float) spectra = pd.DataFrame(spectra).astype(float)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment