gdcc / pyDataverse

Python module for Dataverse Software (dataverse.org).
http://pydataverse.readthedocs.io/
MIT License
63 stars 43 forks source link

'Api' object has no attribute 'get_dataset' #79

Closed kuriwaki closed 3 years ago

kuriwaki commented 3 years ago

Python novice here trying to reproduce the import CSV code from datafest last month.

I get the following after installing pyDataverse today with pip3. What am I doing wrong and how do I complete the rest of the import script?

>>> import io
>>> import pandas as pd
>>> from pyDataverse.api import Api
>>> 
>>> doi = "doi:10.7910/DVN/HIDLTK"
>>> base_url = "https://dataverse.harvard.edu"
>>> api_token = ""
>>> api = Api(base_url, api_token)
>>> resp = api.get_dataset(doi)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Api' object has no attribute 'get_dataset'

I manually copied and pasted the python code @skasberger gave in his slides in this gist - maybe I made typos.

skasberger commented 3 years ago

The problem is, the code was written with 0.2.1, and I released 0.3.0 just a few days ago. i would recommend to update the script like this:

>>> import io
>>> import pandas as pd
>>> from pyDataverse.api import NativeApi
>>> 
>>> doi = "doi:10.7910/DVN/HIDLTK"
>>> base_url = "https://dataverse.harvard.edu"
>>> api = NativeApi(base_url)
>>> resp = api.get_dataset(doi)

Please tell me, if this works now.

kuriwaki commented 3 years ago

That works - thank you. I should have remembered that the versions were different.

I edited the Gist and the first half now works but I'm hitting issues now with the second half involving pd.read_csv where the last line appears to be printing metadata not the first 10 rows of the dataset. But that's a different issue from the title of this issue so I can also file another one.

kuriwaki commented 3 years ago

Never mind, the separate question is now filed in #80.