02-08-2023 04:07 AM
How can I delete a file in DBFS with Illegal character?
Someone put the file named "planejamento_[4098.]___SHORT_SAIA_JEANS__.xlsx" inside the folder /FileStore and I can delete it, because of this error: java.net.URISyntaxException: Illegal character in path at index 24.
I used: dbutils.fs.rm("/FileStore/planejamento_[4098.]___SHORT_SAIA_JEANS__.xlsx")
02-17-2023 04:23 AM
try this
%sh
ls -li /dbfs
if the file is located in a subdirectory you can change the path mentioned above.
the %sh magic command gives you access to linux shell commands.
02-08-2023 04:49 AM
you can try to use the %sh magic command and use rm.
Combined with this little help, it will probably work.
02-16-2023 04:39 AM
Thank you. I tried all the commands but none of them worked because the characters are "[" and "]". 😩
02-16-2023 05:00 AM
it should still be possible.
can you try using ls -li (or ls -ia) first to get a list of files, then use the inode number (first column) and use it in the find- delete command:
> ls -li
> find . -inum <inodenumber> -delete
you can try without the -delete first to see if the file can be found
02-16-2023 12:13 PM
02-17-2023 04:23 AM
try this
%sh
ls -li /dbfs
if the file is located in a subdirectory you can change the path mentioned above.
the %sh magic command gives you access to linux shell commands.
02-17-2023 04:39 AM
Thank you!
It worked out!
Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections.
Click here to register and join today!
Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.