Re: fileinput module not yielding expected results

2019-09-07 Thread Jason Friedman
> > If you're certain that the headers are the same in each file, > then there's no harm and much simplicity in reading them each > time they come up. > > with fileinput ...: > for line in f: > if fileinput.isfirstline(): > headers =

Re: fileinput module not yielding expected results

2019-09-07 Thread Barry Scott
> On 7 Sep 2019, at 16:33, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> > wrote: > >with fileinput ...: >for line in f: >if fileinput.isfirstline(): >headers = extract_headers(line) >else: >pass # process a non-header

Re: fileinput module not yielding expected results

2019-09-07 Thread Dan Sommers
On 9/7/19 11:12 AM, Jason Friedman wrote: $ grep "File number" ~/result | sort | uniq File number: 3 I expected that last grep to yield: File number: 1 File number: 2 File number: 3 File number: 4 File number: 5 File number: 6 As per

fileinput module not yielding expected results

2019-09-07 Thread Jason Friedman
import csv import fileinput import sys print("Version: " + str(sys.version_info)) print("Files: " + str(sys.argv[1:])) with fileinput.input(sys.argv[1:]) as f: for line in f: print(f"File number: {fileinput.fileno()}") print(f"Is first line: {fileinput.isfirstline()}") I