I'm trying to scrape data from large .txt
files online using Python 3.
The data I'm after is reliably in the first 2000 characters of text, and the bandwidth/download time is making download of the entire file quite costly.
Is there any way to download only the first N characters or lines from a remote file?
Something like the following:
import urllib.request
with open(urllib.request.urlopen(myurl)) as myfile:
head= [next(myfile) for x in range(10)]
print(head)