Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 8, 2017 13:47
Show Gist options
  • Select an option

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

Select an option

Save BlogBlocks/b0209dfe11536eca6cfb390ea7e26438 to your computer and use it in GitHub Desktop.
# Where to get the data:
# Crimes_-_2001_to_present.csv
# https://catalog.data.gov/dataset/crimes-2001-to-present-398a4
# THIS IS A BIG FILE - 1.5 gig
# prints a range within the file
#USAGE: Line 0 is the header row
# python PrintRange.py Crimes_-_2001_to_present.csv 0 15
import sys
filename = sys.argv[1]
starT = int(sys.argv[2])
enD = int(sys.argv[3])
#starT = 100
#enD = 150
def printRange(filename,starT,enD):
N=10000
f=open(filename)
count=0
for i in range(N):
count=count+1
line=f.next().strip()
if count > starT:
print "LineNumber :",count-1,"\n",line,"\n"
if count >enD:
sys.exit()
f.close()
if __name__ == "__main__":
printRange(filename,starT,enD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment