In the latest version of pandas (0.19.2) you can directly pass the url

import pandas as pd

url = "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv"
c = pd.read_csv(url)
Answer from inodb on Stack Overflow
🌐
Medium
deallen7.medium.com › how-to-read-csv-data-from-a-url-into-a-pandas-dataframe-b35e70d9e17a
How to read CSV data from a URL into a Pandas DataFrame | by David Allen | Medium
July 26, 2022 - If you’ve ever read a CSV from local storage into your Jupyter notebook, this is going to be a breeze for you. It’s the exact same process. Except instead of passing in a path to the file on your computer, you’ll pass in the URL to the raw CSV. For this example, we’re going to use a raw CSV of US State-county-zip data from github.com: https://github.com/scpike/us-state-county-zip/blob/master/geo-data.csv ... Documentation and tutorials on Python, Pandas, Jupyter Notebook, and Data Analysis.
Discussions

python - Reading Data from URL into a Pandas Dataframe - Stack Overflow
I have a URL that I am having difficulty reading. It is uncommon in the sense that it is data that I have self-generated or in other words have created using my own inputs. I have tried with other More on stackoverflow.com
🌐 stackoverflow.com
python - How to read data from url to pandas dataframe - Stack Overflow
Any suggestion/idea on a better approach to fet this data? EDIT The expexted result should be something like: ... The reader works well but you don’t have the right number of columns in your header. You can get the other columns back using .reset_index() and then rename the columns: >>> df = pd.read_csv(url... More on stackoverflow.com
🌐 stackoverflow.com
September 30, 2021
pandas - Return data from URL with Python - Stack Overflow
I want to read stock data into a pandas dataframe. This question roughly matches what I want to do, but it recommends web scraping. I don't want to rely on web scraping to get my data, as I might n... More on stackoverflow.com
🌐 stackoverflow.com
How to read Data from Url in python using Pandas? - Stack Overflow
I am trying to read the text data from the Url mentioned in the code. But it throws an error: ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 2 url="https://cdn.upgr... More on stackoverflow.com
🌐 stackoverflow.com
January 28, 2019
🌐
DataScientYst
datascientyst.com › how-to-read-csv-directly-from-a-url-in-pandas-and-requests
How to Read CSV Directly from a URL in Pandas and Requests
April 14, 2025 - In this case we can use the following code to read the data: import pandas as pd import io import requests url = "https://raw.githubusercontent.com/softhints/Pandas-Exercises-Projects/refs/heads/main/data/europe_pop.csv" content = requests.get(url).content df = pd.read_csv(io.StringIO(content.decode('utf-8'))) df
🌐
Kaggle
kaggle.com › code › masoudfaramarzi › basics-of-accesing-data-from-urls-using-pandas
Basics of Accesing Data from URLs using Pandas | Kaggle
December 24, 2020 - Explore and run AI code with Kaggle Notebooks | Using data from No attached data sources
🌐
AskPython
askpython.com › python-modules › pandas › read-csv-from-url-pandas
How to read a CSV from a URL using Pandas? - AskPython
April 26, 2023 - Pandas’ built-in function facilitates reading datasets in a variety of formats. Python users can read CSV files (Comma Separated Values files) in numerous ways with the help of the read_csv() function of the Pandas package.
🌐
Skytowner
skytowner.com › explore › reading_url_using_read_csv_in_pandas
Reading URL using read_csv in Pandas
To read a dataset that resides in some URL, directly pass the URL into read_csv(~) like so: url = "https://raw.githubusercontent.com/SkyTowner/sample_data/main/pandas/simple_dataset.csv"
🌐
Saturn Cloud
saturncloud.io › blog › downloading-a-csv-from-a-url-and-converting-it-to-a-dataframe-using-python-pandas
Downloading a CSV from a URL and Converting it to a DataFrame using Python Pandas | Saturn Cloud Blog
May 1, 2026 - try: df = pd.read_csv("downloaded_data.csv") except FileNotFoundError: print("The specified CSV file was not found.") This snippet addresses the scenario where the downloaded file is not found. In this guide, we covered the process of downloading a CSV file from a URL and converting it into a Pandas DataFrame using Python.
Find elsewhere
🌐
Like Geeks
likegeeks.com › home › python › pandas › read json from url using pandas read_json & requests
Read JSON from URL using Pandas read_json & requests
To retrieve JSON data from a URL, you’ll use Pandasread_json method. This function simplifies the process of converting JSON content directly into a Pandas DataFrame. Here’s how you can use pandas.read_json to load data from a URL:
Top answer
1 of 2
1

pd.read_csv does not parse HTML. You might try pd.read_html, but would find that it works on <table> tags, not <pre> tags.

On inspecting the HTML content of the given URL, it is evident that the data is contained in a <pre> tag.

Use something like requests to get the page content, and BeautifulSoup4 to parse the HTML page contents (with an appropriate parsing engine, either lxml or html5lib). Then pull out the content of the <pre> tag, splitting on newlines, slicing to ignore unwanted lines, and then splitting on whitespace.


Minimal working code:

import pandas as pd
import requests
from bs4 import BeautifulSoup

url = 'https://psl.noaa.gov/cgi-bin/data/timeseries/timeseries.pl?ntype=1&var=Zonal+Wind&level=1000&lat1=50&lat2=25&lon1=-135&lon2=-65&iseas=0&mon1=0&mon2=0&iarea=0&typeout=1&Submit=Create+Timeseries'
res = requests.get(url)

# get the text from the 'pre' tag, split it on newlines
# slice off 1 head and 5 tail rows
# (inspect the contents of 'soup.find('pre').text' to determine correct values)
soup = BeautifulSoup(res.content, "html5lib")
data = soup.find('pre').text.split("\n")[1:-5]

df = pd.DataFrame([row.split() for row in data]).apply(pd.to_numeric)
df = df.set_index(df.iloc[:,0])

results in

>>> print(df.head(5))
        0      1      2      3      4      5      6      7      8      9      10     11     12
0
1948  1948  0.878  0.779  0.851  0.393  0.461  0.747  0.867  0.539 -0.106  0.045  0.819  1.506
1949  1949  0.386  1.197  1.154  1.054  0.358  0.645  0.643  0.477  0.128 -0.091  1.500  0.390
1950  1950  0.674  0.973  1.640  0.821  0.572  1.002  0.635  0.196 -0.020  0.268  0.844  1.045
1951  1951  1.524  0.698  0.971  0.790  0.789  0.587  0.682  0.238  0.256  0.035  0.906  1.268
1952  1952  1.524  1.510  1.353  0.705  0.710  1.188  0.412  0.432 -0.091  0.415  0.443  1.509

and

>>> print(df.dtypes)
0       int64
1     float64
2     float64
...
12    float64

This answer is a good starting point for what you're trying to accomplish.

2 of 2
0

Its because the first one directly points to a dataset from storage in .data format but the second url points to a website (which is made up of html, css, json, etc files). You can only use pd.read_csv if you are parsing in a .csv file, and i guess a .data file too since it worked for you.


If you can find a link to the actual .data or .csv file on that website you will be able to parse it no problem. Since its a gov website, they probably will have a good file format.


If you cannot, and still need this data you will have to do some webscraping from that website (like using selenium), then you will need to store them as dataframes, and maybe preprocess it so it gets added like expected.

🌐
Kaggle
kaggle.com › getting-started › 71690
How to convert an URL into pandas dataframe? | Kaggle
My aim is to fetch 1000 rows from a news website. So I wanted to know how to extract the data from an URL and convert it to pandas dataframe. Let it be any n...
🌐
Educative
educative.io › home › courses › data wrangling with python › loading a csv dataset from a url
Loading CSV Datasets from URLs with pandas in Python
Let’s see how we can analyze data from a CSV file using Python by loading the file from a URL. ... df = pd.read_csv('https://raw.githubusercontent.com/CourseMaterial/DataWrangling/main/flowerdataset.csv') ... Line 1: We start by first importing the pandas library using import pandas as pd.
🌐
Educative
educative.io › home › courses › advanced pandas—going beyond the basics › read data from the web
Reading Data from the Web with Pandas in Python
... The exploding volumes of data ... Locator (URL) to the website hosting remote CSV or JSON files we want, the read_csv() and read_json() functions will do the trick....
🌐
Packtpub
subscription.packtpub.com › book › data › 9781801075541 › 2 › ch02lvl1sec10 › reading-data-from-urls
Chapter 2: Reading Time Series Data from Files | Time Series Analysis with Python Cookbook
Grab the DataFrame (at index 15) and assign it to the df variable, and print the returned columns: ... Display the first five rows for Total cases, Total deaths, and the Cases per million columns. df[['Total cases', 'Total deaths', 'Cases per million']].head() ... Most of the pandas reader functions accept a URL as a path.
🌐
GitHub
github.com › upalr › Python-camp › wiki › 1.-Importing-data-from-the-Internet
1. Importing data from the Internet · upalr/Python-camp Wiki · GitHub
October 21, 2017 - # Import package from urllib.request import urlretrieve # Import pandas import pandas as pd # Assign url of file: url url = 'https://s3.amazonaws.com/assets.datacamp.com/production/course_1606/datasets/winequality-red.csv' # Save file locally urlretrieve(url, 'winequality-red.csv') # Read file into a DataFrame and print its head df = pd.read_csv('winequality-red.csv', sep=';') print(df.head())
Author: upalr
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_csv.html
pandas.read_csv — pandas 3.0.6 documentation - PyData |
For file URLs, a host is expected. A local file could be: file://localhost/path/to/table.csv. If you want to pass in a path object, pandas accepts any os.PathLike. By file-like object, we refer to objects with a read() method, such as a file handle (e.g. via builtin open function) or StringIO. ... Character or regex pattern to treat as the delimiter. sep=None detects the separator from the first valid row of the file with Python’s builtin sniffer tool, csv.Sniffer; it is supported only by the Python parsing engine, which will be used automatically.
🌐
Seaborn Line Plots
marsja.se › home › programming › python › using pandas to read json from url
Using Pandas to Read JSON from URL - Erik Marsja
March 15, 2025 - This tutorial focuses on the steps to accomplish this task, building upon our previous discussions on reading JSON with Python more generally. ... First, let us look at a simple example of using Pandas to read JSON from a URL. import pandas as pd # URL containing JSON data url = "http://api.open-notify.org/astros.json" # Read JSON data from URL into a DataFrame df = pd.read_json(url) # Display the dataframe print(df)Code language: PHP (php)