Mustjaab
Mustjaab3w ago

Converting csv to dataframe

I would like to inlcude a feature in my notebook where a user imports a csv and it turns into a dataframe. I'm using mo.ui.file_browser. Is there a way to extract the filepath from FileInfo?
2 Replies
Hall
Hall3w ago
Someone will reply to you shortly. In the meantime, this might help: -# This post was marked as solved by Myles Scolnick. View answer.
Shahmir
Shahmir3w ago
i think you can get it directly
fb = mo.ui.file_browser()
fb.value[0].path # gives you path
fb = mo.ui.file_browser()
fb.value[0].path # gives you path
btw, you can also do this with mo.ui.file
f = mo.ui.file(kind="button", filetypes=[".csv"])

mo.stop(len(f.value) == 0, mo.md("Dataframe viewer"))
df = pl.read_csv(f.value[0].contents)
f = mo.ui.file(kind="button", filetypes=[".csv"])

mo.stop(len(f.value) == 0, mo.md("Dataframe viewer"))
df = pl.read_csv(f.value[0].contents)

Did you find this page helpful?