I have a python script parse.py which in a script open a file, say file1, and then do something, maybe print the total number of characters.
filename = 'file1' f = open(filename, 'r') content = f.read() print filename, len(content)
Right now, I'm using stdout to direct the result to my output file - output
python parse.py >> output
However, I donβt want to do this file manually manually, is there a way to take care of each individual file automatically? how
ls | awk '{print}' | python parse.py >> output
Then the problem is, how could I read the file name from the standard? or are there already some built-in functions to facilitate ls and those types of work?
Thank!
python file pipe stdin stdout
B.Mr.W. Aug 15 2018-12-18T00: 00Z
source share