I use python and I don't know how to do.
I want to read lots of lines in files. But I have to read from second lines. All files have different lines, So I don't know how to do.
Code example is that it read from first line to 16th lines. But I have to read files from second lines to the end of lines. Thank you!:)
with open('filename') as fin:
for line in islice(fin, 1, 16):
print line
You should be able to call next
and discard the first line:
with open('filename') as fin:
next(fin) # cast into oblivion
for line in fin:
... # do something
This is simple and easy because of the nature of fin
, being a generator.
with open("filename", "rb") as fin:
print(fin.readlines()[1:])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With