Nov-15-2025, 10:25 AM
Hello,
I am trying to write basic data to a csv file and I keep getting a (PermissionError: [Errno 13] Permission denied: 'test_csv.csv') error. I have tried moving my csv file (test_csv.csv) to different locations on my C drive but I still get the same error. Can you see any problems with my below code that would cause this error?
Tuurbo46
I am trying to write basic data to a csv file and I keep getting a (PermissionError: [Errno 13] Permission denied: 'test_csv.csv') error. I have tried moving my csv file (test_csv.csv) to different locations on my C drive but I still get the same error. Can you see any problems with my below code that would cause this error?
import os
import csv
def write_to_csv_file():
path = r"C:\Documents\test_csv.csv"
print(os.getcwd())
with open("test_csv.csv", "w") as file:
new_content = "New content to replace the existing content."
file.write(new_content)
print("File content modified successfully!")Thanks,Tuurbo46
