Read/Write single file in DataBricks
You can write and read files from DBFS with dbutils. Use the dbutils.fs.help() command in databricks to access the help menu for DBFS.
You would therefore append your name to your file with the following command:
You are getting the "No such file or directory" error because the DBFS path is not being found. Use dbfs:/ to access a DBFS path. This is how you should have read the file:
f = open("/dbfs/mnt/blob/myNames.txt", "r")
You can open the file in append mode using 'a'
with open("/dbfs/mnt/sample.txt", "a") as f: f.write("append values")
Now you can view the contents using
with open("/dbfs/mnt/sample.txt", "r") as f_read: for line in f_read: print(line)