SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Copy Data Between Data Lake Files Instances Using Python

Copy a root directory from a source SAP HANA data lake Files instance to a target SAP HANA data lake Files instance. A Python script is provided to execute this copy which leverages the SAP HANA Cloud, data lake Files REST API.

Overview

🎓 beginner 15 min. SAP HANA Cloud, Data LakeBeginnerSAP HANA CloudData LakeSAP HANA CloudPython

You will learn

  • How to copy a directory from the source data lake file container to the target data lake file container
Allyson Sherwood A Allyson Sherwood September 21, 2023
Created by April 19, 2023
Contributors

Prerequisites

Prerequisites

Steps

Intro

Note that for simplicity, the same client certificate will be used for both the target and the source instance in this tutorial.


Step 1 Set up a directory in the source data lake Files instance

In this step, we will create a directory called My_Directory with two subdirectories, Subdirectory_1 and Subdirectory_2, with a file in each subdirectory. The files can be of any format, however this tutorial will use text files.

  1. Create and save the following text files locally.

    File_1.txt
    This is my first text file.

    Ensure to recall the location of your text files.

    File_2.txt
    This is my second text file. 
  2. In database explorer, upload these files to your source HANA data lake Files storage (HDLFS) instance. Upload File_1.txt, setting the relative path as My_Directory/Subdirectory_1. This will upload the file and create a new directory My_Directory with subdirectory Subdirectory_1.

    Upload files
    Upload files

    Upload first file
    Upload first file

  3. Upload File_2.txt using the relative path My_Directory/Subdirectory_2.

Step 2 Set up a Python script
+
Step 3 Set up a copy script
+
Step 4 Run the copy script
+
Step 5 Knowledge check
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 5
1. Set up a directory in the source data lake Files instance 2. Set up a Python script 3. Set up a copy script 4. Run the copy script 5. Knowledge check

Learn more →