I have a folder with csv formated documents with a .arw extension. Files are named as
1.arw, 2.arw, 3.arw ... etc.
I would like to write a code that reads all the files, checks and replaces the forwardslash
/ with a dash
-. And finally creates new files with the replaced character.
The code I wrote as follows:
for i in range(1,6): my_file=open("/path/"+str(i)+".arw", "r+") str=my_file.read() if "/" not in str: print("There is no forwardslash") else: str_new = str.replace("/","-") print(str_new) f = open("/path/new"+str(i)+".arw", "w") f.write(str_new) my_file.close()
But I get an error saying:
'str' object is not callable.
How can I make it work for all the files in a folder? Apparently my for loop does not work.