I am using Ubuntu with python 2.7,
I need to take all the files in a folder, and count the lines in every file seperatly and dump it to a file.
I found how to do it via terminal directly using parallel processing here
It crashes when I try:
subprocess.Popen('ls %s* | parallel -k zcat {} | wc -l >%s'%(dir,outputfile), shell=True)
Now I am trying to use that terminal command via python, seems like it can't take the list of files and use them as files but only to count the length of the files list.
p1 = subprocess.Popen(["ls", dest], stdout=subprocess.PIPE)
output = subprocess.check_output(["wc", "-l"], stdin=p1.stdout)
Gives me the number of files in the folder, when I want a list of how many lines there are in each file.
How can I use python to execute a command that will: give me a list of how many lines there are, at every file in a folder, and will do it using parallel (or any other good multi coring method)