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]:
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:
sepy = M00.radio("separator (Y file): ", options=[";", ","], key=2)
hdry = M00.radio("samples name (Y file)?: ", options=["no", "yes"], key=3)
sepy = M00.radio("Select separator (Y file) - _detected_: " + str(find_delimiter('data/'+ycal_csv.name)),
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
else: col = False
else:
......@@ -71,15 +73,14 @@ if file == files_format[0]:
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)
yfile = pd.read_csv(ycal_csv, decimal='.', sep=sepy, index_col=col)
if yfile.shape[1]>0 and xfile.shape[1]>0 :
spectra, meta_data = col_cat(xfile)
y, idx = col_cat(yfile)
if y.shape[1]>1:
yname = M00.selectbox('Select target', options=y.columns)
y = y.loc[:,yname]
chem_data, idx = col_cat(yfile)
if chem_data.shape[1]>1:
yname = M00.selectbox('Select target', options=chem_data.columns)
y = chem_data.loc[:,yname]
else:
y = y.iloc[:,0]
y = chem_data.iloc[:,0]
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