Is there an elegant way of skipping first line of file when using python
fileinput module?
I have data file with nicely formated data but the first line is header. Using fileinput
I would have to include check and discard line if the line does not seem to contain data.
The problem is that it would apply the same check for the rest of the file.
With read()
you can open file, read first line then go to loop over the rest of the file. Is there similar trick with fileinput
?
Is there an elegant way to skip processing of the first line?
Example code:
input fileinput
# how to skip first line elegantly?
for line in fileinput.input(["file.dat"]):
data = proces_line(line);
output(data)