Community
I'm currently trying to implement a program that includes the following shell command:
/home/myfolder/ParZu/parzu -l tagged < /home/myfolder/raw_text_de/raw_text_de0.txt >/home/myfolder/raw_text_de0_parsed.txt
/home/myfolder/ParZu/parzu is the program I want to run, -l and tagged are options to go with the program and I want to feed in my raw_text_de0.txt and write the result into another file raw_text_de0_parsed.txt.
The thing is, that I have to do this more than 400 times (for file raw_text_de1.txt, raw_text_de2.txt....), which is why I really want to automatize it.
I tried several things that have been suggested here on Stackoverflow, but none seems to work. My current attempt looks as follows:
path_texts = '/home/myfolder/raw_text_de'
filename = os.listdir(path_texts)
##create list of filenames ('/home/myfolder/raw_text_de/raw_text_de0.txt', ...)
infile_list = []
for fname in filename:
new_filename = '/home/myfolder/raw_text_de/' + fname
infile_list.append(new_filename)
##go through the files in the infile_list and include it in shell command
for item in infile_list:
p = subprocess.call(['/home/myfolder/ParZu/parzu', '-l', 'tagged', '<', item, '>', item + 'parsed.txt'])
However, this doesn't work. It apparently calls the program, but then gets stuck. I know that it is difficult to answer this question without being able to try it, but I hope someone has an idea about what could be wrong or missing.