Created
November 17, 2016 08:55
-
-
Save srgrn/4098ae1ddcbeaa8c096da501c5c14836 to your computer and use it in GitHub Desktop.
download a gzipped file line by line (for example http://csr.lanl.gov/data/cyber1/ files)
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
import urllib.request | |
import gzip | |
N = 200000 | |
def read_line_by_line(url,handlefunc,**kwargs): | |
with gzip.open(urllib.request.urlopen(url),'r') as f: | |
for i in range(N): | |
try: | |
arr =f.readline().decode('ascii').strip().split(',') | |
handlefunc(arr,kwargs) | |
except StopIteration: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment