Python extract n line from the input file
Using a generator, we can process the file reading job more elegantly.
Well, Python views the open file as a generator obj. So we can warp it into another function.
For example:
#only proceed the first n line in python
def skip_line(input_file,n):
for i in range(n):
next(input_file)
Just as simple as this!
Written on December 4, 2013