Load files from folder and save in another folder [python]
I am aware that my problem is trivial, but I can not handle it by myself: I need to load files from one folder and save parsed files in it to another. I have a code like this:
for file in os.listdir("path_to_folder"):
print(file)
write_func(f"{file}")
write_func works like in should, it can not be necessary to put it but looks like this:
def write_func(file):
with open(f"./corrected/corrected_{file}", "w") as output:
for id, seq in rename(file):
output.write(f">{id}\n{seq}\n")
print(file) shows names of files within the folder. When I trying to write parsed files in corrected folder I hav开发者_运维技巧e an error:
No such file or directory: 'name.txt'
The error rise because that file is inside "path to folder" not in the working directory.
The problem I have is that I need to put in variable file not only the names of files within, instead I need to include path to folder. I am not sure if am I clear. Kindly help.
精彩评论