Fillmore wrote: > > learning Python from Perl here. Want to do things as Pythonicly as possible. > > I am reading a TSV, but need to skip the first 5 lines. The following > works, but wonder if there's a more pythonc way to do things. Thanks > > ctr = 0 > with open(prfile,mode="rt",encoding='utf-8') as pfile: > for line in pfile: > ctr += 1 > > if ctr < 5: > continue > > allVals = line.strip().split("\t") > print(allVals)
for lineno, line in enumerate(pfile, start=1): will save you maintaining your own counter. But other than that, nah, that's pretty much the approach you're looking for. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list