• United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

How can I add a file to Data Asset by Notebook?

0600021H1K gravatar image
Question by kazuhiro-jp  (71) | Mar 26, 2018 at 03:20 AM watsoncognos-dashboard-embeddeddata-science-experiencedynamic-dashboard-embedded

Referring the following guide, I created a Notebook in Watson Studio which upload data to the project's IBM Cloud Object Storage Bucket. The file was added to the project's bucket, but it was not added to the project's Data Asset tab.

Working With IBM Cloud Object Storage In Python https://medium.com/ibm-data-science-experience/working-with-ibm-cloud-object-storage-in-python-fe0ba8667d5f

How can I add a data to Data Asset tab in the project by Notebook?

Notebook

 credentials = {
     'IBM_API_KEY_ID': 'xxx',
     'IAM_SERVICE_ID': 'xxx',
     'ENDPOINT': 'xxx',
     'IBM_AUTH_ENDPOINT': 'xxx',
     'BUCKET': 'xxx',
     'FILE': 'xxx.csv'
 }
 
 from ibm_botocore.client import Config
 import ibm_boto3
 
 cos = ibm_boto3.client(service_name='s3',
     ibm_api_key_id=credentials['IBM_API_KEY_ID'],
     ibm_service_instance_id=credentials['IAM_SERVICE_ID'],
     ibm_auth_endpoint=credentials['IBM_AUTH_ENDPOINT'],
     config=Config(signature_version='oauth'),
     endpoint_url=credentials['ENDPOINT'])
 
 df_data_1.to_csv("shimac_test_before_upload.csv", encoding="utf-8")
 with open('shimac_test_before_upload.csv', 'rb') as data:
     cos.upload_fileobj(data,  credentials['BUCKET'], 'shimac_test_afer_upload.csv')

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

1 reply

  • Sort: 
310000KFKH gravatar image

Answer by Charles C Gomes (121) | Apr 02, 2018 at 05:21 PM

Hi,

You can use project-lib Library to save the dataframe directly as data asset in your project.

 #Save dataframe as csv file to storage
 project.save_data(data=df.to_csv(index=False),file_name='iris1.csv',overwrite=True)

For full reference, check this:- https://medium.com/ibm-data-science-experience/control-your-dsx-projects-using-python-c69e13880312

Thanks, Charles.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

137 people are following this question.

Answers

Answers & comments

Related questions

Error opening workbook in DSX 0 Answers

error in installing watson-machine-learning-client 1 Answer

Unable to initialise the dynamic dashboard API due to frame-ancestors Security Policy Directive 2 Answers

How can I get dashboardSpec information? 4 Answers

What is Dynamic Dashboard Embedded? 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • DataPower
  • Decision Optimization
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges