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

2017-04-05 Thread Skip Montanaro
David> This is something very different.

David> New thinking and methods are needed.

David> Try to click on the following link

David> European Commission : CORDIS : Search : Results page


Hopefully not too very different. :-)

Looks to me like UTF-32 or UTF-16 encoding, or one of those encodings which
needs a BOM. I was able to read it using Python's csv module (this in
Python 3):

>>> f = open("cordis-search-results.csv")
>>> rdr = csv.DictReader(f, delimiter=';')
>>> for row in rdr:
...   print(row["Title"])
...
Incremental Nonlinear flight Control supplemented with Envelope ProtecTION
techniques
AdvancEd aicRaft-noIse-AlLeviation devIceS using meTamaterials
Imaging Biomarkers (IBs) for Safer Drugs: Validation of Translational
Imaging Methods in Drug Safety Assessment (IB4SD-TRISTAN)
Big Data for Better Outcomes, Policy Innovation and Healthcare System
Transformation (DO->IT)
Translational quantitative systems toxicology to improve the understanding
of the safety of medicines
Real world Outcomes across the AD spectrum for better care: Multi-modal
data Access Platform
Models Of Patient Engagement for Alzheimer’s Disease
INtestinal Tissue ENgineering Solution
Small vessel diseases in a mechanistic perspective: Targets for
InterventionAffected pathways and mechanistic exploitation for prevention
of stroke and dementia
How does dopamine link QMP with reproductive repression to mediate colony
harmony and productivity in the honeybee?


Note that I had to specify the delimiter as a semicolon. That also works
with pandas.read_csv:

>>> df = pd.read_csv("cordis-search-results.csv", sep=";")
>>> print(df["Title"])
0Incremental Nonlinear flight Control supplemen...
1AdvancEd aicRaft-noIse-AlLeviation devIceS usi...
2Imaging Biomarkers (IBs) for Safer Drugs: Vali...
3Big Data for Better Outcomes, Policy Innovatio...
4Translational quantitative systems toxicology ...
5Real world Outcomes across the AD spectrum for...
6Models Of Patient Engagement for Alzheimer’s D...
7   INtestinal Tissue ENgineering Solution
8Small vessel diseases in a mechanistic perspec...
9How does dopamine link QMP with reproductive r...
Name: Title, dtype: object


Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2017-04-05 Thread David Shi via Python-list
Hi, Skip,
This is something very different.
New thinking and methods are needed.
Try to click on the following link
European Commission : CORDIS : Search : Results page


| 
| 
| 
|  |  |

 |

 |
| 
|  | 
European Commission : CORDIS : Search : Results page
European Commission |  |

 |

 |



Is there a way to capture the file?
Regards.
David
 

On Wednesday, 5 April 2017, 17:19, Skip Montanaro 
 wrote:
 

 I'm not positive, but try passing response to read_csv() instead of reading 
the bytes yourself.
Skip
On Apr 5, 2017 10:38 AM, "David Shi via Python-list"  
wrote:



I tried the following codes:
import urllib2response = urllib2.urlopen('http:// cordis.europa.eu/search/ 
result_en?q=uk=csv') myCSV = response.read()
myFile = pd.read_csv(myCSV)

but, it did not work well.
Can any one help?
Regards.
David
--
https://mail.python.org/ mailman/listinfo/python-list



   
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2017-04-05 Thread Peter Otten
David Shi via Python-list wrote:

> I tried the following codes:
> import urllib2response =
> 
urllib2.urlopen('http://cordis.europa.eu/search/result_en?q=uk=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=csv;
>>> df = pandas.read_csv(url, sep=";")
>>> df.Title[0]
'Incremental Nonlinear flight Control supplemented with Envelope ProtecTION 
techniques'


-- 
https://mail.python.org/mailman/listinfo/python-list


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

2017-04-05 Thread Skip Montanaro
I'm not positive, but try passing response to read_csv() instead of reading
the bytes yourself.

Skip

On Apr 5, 2017 10:38 AM, "David Shi via Python-list" 
wrote:

>
>
> I tried the following codes:
> import urllib2response = urllib2.urlopen('http://cordis.europa.eu/search/
> result_en?q=uk=csv')myCSV = response.read()
> myFile = pd.read_csv(myCSV)
>
> but, it did not work well.
> Can any one help?
> Regards.
> David
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list