'writing appending text file from databricks to azure adls gen1

I want to write kind of a log file back to azure adls gen1 I can write (not append) using

dbutils.fs.put(filename,"random text")

but i cant append it using

with open("/dbfs/mnt/filename.txt","a"):
f.write("random text")

it give me error

1 with  open("/dbfs/mnt/filename.txt", "a") as f:
----> 2   f.write("append values")

OSError: [Errno 95] Operation not supported

alternatively, i tried using logger.basicconfig(logging.basicConfig(filename='dbfs:/mnt/filename.txt', filemode='w')

but looks like its not writing into the path. can anyone help please



Solution 1:[1]

Append Only (‘a’) : Open the file for writing. The file is created if it does not exist. The handle is positioned at the end of the file. The data being written will be inserted at the end, after the existing data.

file = open("myfile.txt","a")#append mode 
file.write("Today \n") 

enter image description here

Output of append file:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1