Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 19, 2017 00:26
Show Gist options
  • Save BlogBlocks/fceef9445be08ee1c2ee76a56451a140 to your computer and use it in GitHub Desktop.
Save BlogBlocks/fceef9445be08ee1c2ee76a56451a140 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python
"""
View the head and as many lines as you wish
the last argv 9 will print the head and 7 lines
eight lines total
Usage:
python viewCSVlines.py co2.csv 8
"""
import sys
filename = sys.argv[1]
num = sys.argv[2]
num = int(num)
with open(filename) as myfile:
head = [next(myfile) for x in xrange(num)]
mystring = ''.join(head)
print mystring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment