Dataphin offers tenant-level management of third-party libraries. To utilize Python third-party libraries in Python computation tasks within Dataphin, you must first install the required Python modules via the third-party library feature. This topic guides you through the process of managing third-party libraries for Python computation task development in Dataphin.
Case description
This example demonstrates the use of the xlrd third-party library.
Procedure
Step 1:Install the Python module.
Navigate to the top menu bar on the Dataphin home page and single click Management Center > System Settings.
Access the Install Python Module dialog box by following these steps:
Single click Python Third-Party Package > Python Module > Install Python Module.

In the Install Python Module dialog box, set the following parameters:
Parameter
Description
Module Name
Type in xlrd as the module name.
Python Version
Choose the Python 3.7 version.
Installation Method
Opt for the Online Installation method.
Click OK and wait for the
xlrdmodule to finish installing.
Step 2:Create a Python computation task and introduce the third-party library
On the Dataphin home page, navigate to the top menu bar and single click Development > Data Development.
To open the New PYTHON Task dialog box, follow these steps:
Select the project (Dev-Prod mode requires selecting the environment) > Single click Script Task > Click the New Icon
> Choose PYTHON.
In the New PYTHON Task dialog box, configure the task parameters as follows:
Parameter
Description
Task Name
Specify the code task's name, such as xlrd package test.
Schedule Type
Choose One-Time Task.
Select Directory
Select the directory to store the task.
Use Template
By default, this is set to Off.
Python Third-Party Package
Select the xlrd package successfully installed in Step 1.
Description
Provide a brief description of the task, for instance, xlrd package test.
Click OK.
On the Python task code editor, select Python 3.7 and begin coding. The sample code for this case is as follows:
Notedataphin.xlsresources can reference any .xls file uploaded to Dataphin, by replacing the resource name with the one provided during the upload. For more information, see the referenced document and .@resource_reference{"dataphin.xls"} # Reference dataphin.xls resource # Import xlrd module. import xlrd wb = xlrd.open_workbook('dataphince.xls') # Open excel sh = wb.sheet_by_name('Sheet1') # Locate worksheet by workbook # Traverse excel, print all data for i in range(sh.nrows): print(sh.row_values(i))Save and submit the Python task on the code editor page.
Click the run code icon
.Click the submit code icon
in the upper right corner of the page.
Enter remarks on the Submit Remarks page.
Click OK And Submit.