Last active
December 8, 2017 13:47
-
-
Save BlogBlocks/27a182247fab43b5f054af8758fef354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Where to get the data: | |
# https://catalog.data.gov/dataset/crimes-2001-to-present-398a4 | |
# THIS IS A BIG FILE - 1.5 gig | |
# prints the Headers and the First Line | |
# USAGE EXAMPLE: python HeadFirst.py Crimes_-_2001_to_present.csv | |
import sys | |
filename = sys.argv[1] | |
def headFirst(filename): | |
N=1000 | |
f=open(filename) | |
count=0 | |
starT = 0 | |
enD = 1 | |
for i in range(N): | |
count=count+1 | |
line=f.next().strip() | |
if count > starT: | |
print "LineNumber :",count,"\n",line,"\n" | |
if count >enD: | |
sys.exit() | |
f.close() | |
if __name__ == "__main__": | |
headFirst(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment