Closed juliohm closed 1 year ago
Hey! This is not possible because of browser security: https://developer.mozilla.org/en-US/docs/Web/API/File/name
That is interesting. How do people usually load the data from other directories in notebooks then?
I am particularly interested in loading XLSX files with XLSX.readxlsx("/path/to/file.xlsx")
.
You can do that without the file picker; if you can make sure that the file exists you can use an absolute path; if not, upload the file somewhere and download it in a cell (Downloads.download returns a path you can open)
Not sure I follow @pankgeorg. The file can live anywhere on the user disk. He/she will select the file, you mean I should dump the data
key of the FilePicker to a new file in a specific place and then use that absolute path instead?
No - if the file is user defined you can read from the IO object in the file picker Dict: it will be a UInt8 under "data" (file_data["data"]). Does this not work for you?
I can read the data but XLSX.jl expects a filename in XLSX.readxlsx()
Em ter., 7 de mar. de 2023 18:20, Παναγιώτης Γεωργακόπουλος < @.***> escreveu:
No - if the file is user defined you can read from the IO object in the file picker Dict: it will be a UInt8 under "data" (file_data["data"]). Does this not work for you?
— Reply to this email directly, view it on GitHub https://github.com/JuliaPluto/PlutoUI.jl/issues/246#issuecomment-1458890557, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3NAPC7N2ULE5X464VDW26RCZANCNFSM6AAAAAAVSQ2KTA . You are receiving this because you authored the thread.Message ID: @.***>
if you need to, you can write the UInt8 array to a (temp) file and pass that to XLSX.
I can read the data but XLSX.jl expects a filename in XLSX.readxlsx()
@juliohm in actuality you can do the following,
@bind myxlsxfile FilePicker()
and then
workbook = XLSX.readxlsx(myxlsxfile["data"] |> IOBuffer)
That is, readxlsx
now supports both reading from a filename or from IO
.
The FilePicker returns a dictionary with the
name
key holding the basename of the selected file. With only the basename it is impossible to recover the full path of the file for further processing with IO packages.Can this
name
key hold the absolute path instead?