79308035

Date: 2024-12-25 16:58:55
Score: 0.5
Natty:
Report link

You question is very generic.

To read:

# Read a file from the workspace
with open("/dbfs/workspace/<folder>/<file>.txt", "r") as file:
    content = file.read()
    print(content)

To write:

# Write a file to the workspace
with open("/dbfs/workspace/<folder>/<file>.txt", "w") as file:
    file.write("This is a test file.")

Sometime I use dbutils API, here is some examples:

# Write a file to the workspace
dbutils.fs.put("workspace:/shared_folder/example.txt", "This is a test file.")

# Read the file
content = dbutils.fs.head("workspace:/shared_folder/example.txt")
print(content)

Lets me know if above is not working, I will help more. Cheers

Reasons:
  • Blacklisted phrase (1): Cheers
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Ali Saberi