Using R, how do we write csv file to say dbfs:/tmp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 08:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 05:40 AM
Hi Thiam,
Thank you for reaching out to us. In this case it seems that you have written a file to the OS /tmp and tried to fetch the same folder in DBFS.
Written >> /tmp/TotalData.csv
Reading >> /dbfs/tmp/TotalData.csv
Please try to execute write.csv with the following path instead:
write.csv(TotalData,file='/dbfs/tmp/TotalData.csv',row.names = FALSE)
%fs ls /tmp
Then you will see the file in DBFS. If your intention was to write it to the OS /tmp, please do the following:
write.csv(TotalData,file='/tmp/TotalData.csv',row.names = FALSE)
%sh ls /tmp
%sh allows you to run shell code on the OS while %fs is used for DBFS file access.
Please read the following documentation for more information:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 05:18 PM
%r
write.csv(df,file='/tmp/df.csv',row.names = FALSE)
%fs ls /tmp
above does not show that the file df.csv exist
below will have error:
%r
write.csv(df,file='/dbfs/tmp/df.csv',row.names = FALSE)
Warning in file(file, ifelse(append, "a", "w")) :
cannot open file '/dbfs/tmp/df.csv': No such file or directory
Error in file(file, ifelse(append, "a", "w")) :
cannot open the connection
Some(<code style = 'font-size:10pt'> Error in file(file, ifelse(append, "a", "w")): cannot open the connection </code>)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 05:20 PM
please see above. thanks.