Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 19, 2017 00:34
Show Gist options
  • Select an option

  • Save BlogBlocks/308f5b650cea1ae51b8566ea36d6d749 to your computer and use it in GitHub Desktop.

Select an option

Save BlogBlocks/308f5b650cea1ae51b8566ea36d6d749 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python
#Author: JackNorthrup
#Usage : python viewNlines.py data/co2.csv 5
import sys
PATH= sys.argv[1]
try:
N = int(sys.argv[2])
except ValueError:
print "path is to be followed by number of lines to read"
sys.exit(1)
def Nlines(PATH,N):
f=open(PATH)
for i in range(N):
line=f.next().strip()
print line
f.close()
if __name__ == "__main__":
Nlines(PATH,N)
@BlogBlocks

Copy link
Copy Markdown
Author

made public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment