How to capture a CSV file and read it into a Pandas Dataframe?

Peter Otten __peter__ at web.de
Wed Apr 5 12:24:29 EDT 2017


David Shi via Python-list wrote:

> I tried the following codes:
> import urllib2response =
> 
urllib2.urlopen('http://cordis.europa.eu/search/result_en?q=uk&format=csv')myCSV
> = response.read() myFile = pd.read_csv(myCSV)
> 
> but, it did not work well.
> Can any one help?

Looks like read_csv() accepts an URL:

>>> import pandas
>>> url = "http://cordis.europa.eu/search/result_en?q=uk&format=csv"
>>> df = pandas.read_csv(url, sep=";")
>>> df.Title[0]
'Incremental Nonlinear flight Control supplemented with Envelope ProtecTION 
techniques'





More information about the Python-list mailing list