+ 3
Unable to delete a csv file
Anyone please help me and getting error message. os.remove(Name_csv_path) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process https://code.sololearn.com/c414ux1K3c7w/?ref=app
6 Antworten
+ 6
it is executed on sololearn server so probably no possible to delete there
+ 2
os.remove() must be outside the with block
+ 2
Make sure the file is not open in any application and try again
+ 1
You can't delete the file because you forgot to close it. That's exactly why you use context managers when dealing with files:
with open('file.txt', 'rt') as f:
# do something with file
# file is closed automatically
+ 1
Tried 'with' statement and it's not deleting
+ 1
Note that codecs.open is obsolete in Python 3.x:
https://stackoverflow.com/questions/5250744/difference-between-open-and-codecs-open-in-python