Reputation: 4564
I came to know this source to import data. I tried but not successful in importing the data
https://public.opendatasoft.com/explore/embed/dataset/us-zip-code-latitude-and-longitude/table/
my code:
from urllib.request import urlopen, Request
### Import USA ZIP codes,counties, latitudes
usurl = 'https://public.opendatasoft.com//explore//embed//dataset//us-zip-code-latitude-and-longitude//table//'
query_url = Request(usurl)
url_response = urlopen(query_url)
read_response = url_response.read()
print (read_response)
b'\n<!DOCTYPE html>\n<html lang="en">\n <head>\n \n \n\n \n
<title>Opendatasoft</title>\n <link rel="stylesheet"
type="text/css" href="/static/vendor/font-awesome-4.7.0/css/font-awesome.min.css">\n <link rel="styleshe....
Presently I see no data but a string text.
Upvotes: 2
Views: 339
Reputation: 3158
JS is creating the table and rendering of javascript in a request does not work. a workaround can be:
url='https://public.opendatasoft.com/explore/dataset/us-zip-code-latitude-and-longitude/download/?format=csv&timezone=America/New_York&lang=en&use_labels_for_header=true&csv_separator=%3B'
df=pd.read_csv(url,sep=";")
Upvotes: 2