1

I'd like to copy a file to local memory on DSX so that I can create a pandas dataframe using read_csv. I don't want to use the given "insert to code" option because that assumes column headers and it isn't as pretty to code. Here is my code:

import swiftclient

IBM_Objectstorage_Connection = swiftclient.Connection(key=objStorCred['password'],
                                                  authurl=objStorCred['auth_url'],
                                                  auth_version='3',
                                os_options={"project_id": objStorCred['projectId'],
                                            "user_id": objStorCred['userId'],
                                            "region_name": objStorCred['region']})

x = IBM_Objectstorage_Connection.get_account()

I've tried the object storage admin credentials and the credentials for the container. Neither work. I'm trying to copy what was done in this tutorial, but it doesn't seem to be working. Here is my error:

Authorization Failure. Authorization failed: The resource could not be found. (HTTP 404)

Any help would be greatly appreciated!

Ross Lewis
  • 755
  • 2
  • 7
  • 17
  • 1
    Did you try the code snippet from this tutorial from the community area: https://datascience.ibm.com/exchange/public/entry/view/07db16e78e1722931e27c074ebe343ae – Sumit Goyal May 12 '17 at 20:25
  • That uses the same logic from the "insert into code" functionality. I would like to access it in the same way that the [this tutorial](https://developer.ibm.com/recipes/tutorials/using-ibm-object-storage-in-bluemix-with-python/) access it. – Ross Lewis May 12 '17 at 20:44

1 Answers1

2

Did you take a look at the get_file_content(credentials) method mentioned in the following notebook:

https://apsportal.ibm.com/analytics/notebooks/461e1a46-243c-4264-98fb-653884ed27f5/view?access_token=e5eb80cb75eae7e2d8ac4306eece1d1345a6c59a180eb284fb79aa04d3ccb7fe

content_string = get_file_content(credentials_1)
precipitation_df = pd.read_csv(content_string)

I have used it many times before. Hope this helps.

Liran Funaro
  • 2,750
  • 2
  • 22
  • 33
RajeshK
  • 36
  • 1
  • I ended up using this solution, but because the csv doesn't have headers, I lose one of the rows and have to overwrite the headers. The solution I was looking for was the ability to download from object storage, then use read_csv on the local copy. – Ross Lewis May 13 '17 at 22:12
  • I didn't notice. It did help! Thank you! This wasn't exactly what I was asking, but it was a way to get to what I wanted. I'll mark this as answered. – Ross Lewis May 14 '17 at 00:53