+ 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

19th Jan 2019, 9:42 PM
Raj Charan
6 odpowiedzi
+ 6
it is executed on sololearn server so probably no possible to delete there
19th Jan 2019, 10:15 PM
Hubert Dudek
Hubert Dudek - avatar
+ 2
os.remove() must be outside the with block
20th Jan 2019, 10:52 AM
Anna
Anna - avatar
+ 2
Make sure the file is not open in any application and try again
22nd Jan 2019, 5:11 AM
Dan Rhamba
Dan Rhamba - avatar
+ 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
20th Jan 2019, 7:12 AM
Anna
Anna - avatar
+ 1
Tried 'with' statement and it's not deleting
20th Jan 2019, 10:28 AM
Raj Charan
21st Jan 2019, 2:27 PM
Kirk Schafer
Kirk Schafer - avatar