edit-icon download-icon

Import local data

Last Updated: Mar 26, 2018

DataWorks support importing local data by using the following two methods:

  • Upload the data in locally stored text files to the table in the workspace.

  • Use the data integration module to import business data from various data sources to the workspace.

Prerequisites

Use Chrome 48 or later versions

The limits of uploading local text files are as follows:

  • File type: Only .txt and .csv formats are supported.

  • File size: No more than 10 MB.

  • Operation object: If partition tables are imported, the partitions must not contain any Chinese characters.

This article describes how to upload local files to DataWorks by taking banking.txt as an example.

Procedure

  1. Click Import and select Import local data.

  2. Select a local data file. Configure import details and click Next.

  3. If the table for the data to import already exists, enter at least two letters to search for the table name.

    If the table for the data to import does not exist, click Create a Table. Enter the statements of table creation, and click OK.

    The statements of table creation are as follows:

    1. CREATE TABLE IF NOT EXISTS bank_data
    2. (
    3. age BIGINT COMMENT 'Age',
    4. job STRING COMMENT 'Job type',
    5. marital STRING COMMENT 'Marital status',
    6. education STRING COMMENT 'Educational level',
    7. default STRING COMMENT 'Ownership of credit cards',
    8. housing STRING COMMENT 'Housing loan',
    9. loan STRING COMMENT 'Loan',
    10. contact STRING COMMENT 'Contact information',
    11. month STRING COMMENT 'Month',
    12. day_of_week STRING COMMENT 'Day of the week',
    13. duration STRING COMMENT 'Duration',
    14. campaign BIGINT COMMENT 'Number of contacts made for this campaign',
    15. pdays DOUBLE COMMENT 'How long ago was the last contact',
    16. previous DOUBLE COMMENT 'Number of contacts with the customer previously',
    17. poutcome STRING COMMENT 'Results of previous marketing campaigns',
    18. emp_var_rate DOUBLE COMMENT 'Employment change rate',
    19. cons_price_idx DOUBLE COMMENT 'Consumer price index',
    20. cons_conf_idx DOUBLE COMMENT 'Consumer confidence index',
    21. euribor3m DOUBLE COMMENT 'Euro deposit rate',
    22. nr_employed DOUBLE COMMENT 'Number of employees',
    23. y BIGINT COMMENT 'Ownership of fixed term deposits'
    24. ) PARTITIONED BY(pt STRING) ;

    Note:

    • You can only edit and run one statement of table creation when creating the table. Statements are separated by “;” if you are editing more than one statement. But only the first statement can be run.

    • The MaxCompute SQL syntax is required in the statement of table creation. This syntax is slightly different from the standard SQL. For more SQL syntaxes, see DDL statements.

    After the table is created, a New table is created message appears in the upper right corner of the page.

  4. After selecting the table name for the data to import, select the field matching method (“By location” is selected in this example). After “By location” is selected, a Click Test to check whether the partition exists message appears. After the test is complete, click Import.

    Note:

    The test function is only used to check whether the partition exists. If it exists, append the partition. If it does not exist, create a partition without entering any Chinese characters.

    After the file is imported, the system tells you whether your data import is successful or not.

Thank you! We've received your feedback.