fileinput module not yielding expected results

Barry Scott barry at barrys-emacs.org
Sat Sep 7 12:17:54 EDT 2019



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

If you always know you can skip the first line I use this pattern

with fileinput ...:
    next(f) # skip header
    for line in f:
	# process a non-header line here

Barry


More information about the Python-list mailing list