edit-icon download-icon

Upload a local file

Last Updated: Mar 16, 2018

In this article, we use creation of the tables bank_data and result_table as an example to describe how to create a table and upload data. The table of bank_data stores the business data, while the result_table stores the results after data analysis.

Procedure

Follow these steps to create bank_data.

  1. Log on to the project and select Data Development > New > Create Table.

    1

  2. Enter the table creation statements, and click OK. For more information on table creation SQL syntax, see MaxCompute-based table creation, view, and deletion.

    The statements used for table creation in this example 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 'credit card ownership',
    8. housing STRING COMMENT 'mortgage',
    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 'contact times during the campaign',
    15. pdays DOUBLE COMMENT 'time interval from the last contact',
    16. previous DOUBLE COMMENT 'previous contact times with the customer',
    17. poutcome STRING COMMENT 'marketing result',
    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 'has time deposit or not'
    24. );
  3. After the table is created, click Table Query in the left-side navigation pane and enter the table name for search.

    TableQuery

Create result_table

Follow these steps to create result_table

  1. Click Data Development > New > Create Table.

  2. On the Create Table page, enter the table creation statements, and click OK. The statements used for table creation are as follows:

    1. CREATE TABLE IF NOT EXISTS result_table
    2. (
    3. education STRING COMMENT 'educational level',
    4. num BIGINT COMMENT 'number of people'
    5. );
  3. After the table is created, click Table Query in the left-side navigation pane and enter the table name for search.

Upload local data to bank_data

DataWorks supports the following operations:

  • Upload data in local text files to a table in the workspace.

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

Note:

This section uses local files as the data source. Local text file uploads have the following limits:

  • File type: Only .txt and .csv files are supported.
  • File size: The file size cannot exceed 10 MB.
  • Operation objects: Partition and non-partition tables can be imported, but Chinese partition values are not supported.

Using the import of the local file banking.txt to DataWorks as an example, the instruction is as follows:

  1. Click Import > Import Local Data.

    122

  2. Select a local data file, configure the import information, and click Next.

    4

  3. Enter at least two letters to search for the table by name. Select the table to which the data is to be imported, for example, bank_data.

    To create a new table, click Create Table.

    5

  4. Select the field matching method (“Match by Position” is used in this example), and click Import.

    6

  5. After the file is imported, the system displays a data import success or failure prompt.

Other data import methods

Create a data synchronization task

Applicability:

The data can be saved in multiple source types such as RDS, MySQL, SQL Server, PostgreSQL, MaxCompute, ApsaraDB for Memcache, DRDS, OSS, Oracle, FTP, dm, HDFS, and MongoDB.

For more information, see Create a data synchronization task.

Upload a local file

Applicability:

The file size cannot exceed 10 MB, and only .txt and .csv files are supported. Only non-partitioned tables are supported.

For information on DataWorks local file uploads, see the Upload local data to bank_data section.

Use Tunnel commands to upload files

Applicability:

Local files and other resource files are larger than 10 MB.

Using the Tunnel commands provided by the MaxCompute Client to upload or download data, you can upload a local data file to a partitioned table.

For more information, see Tunnel command operations.

Use DataX open-source tools

Applicability:

DataX can import local data in batches. The imported data must have a two-dimensional table structure. This method can be applied to some of the aforementioned scenarios as well.

For more information about DataX open-source tools, see DataX open-source website.

Subsequent steps

You have learned how to create a table and upload data. You can go to the next tutorial for further study. This tutorial demonstartes how to create a flow for further data analysis and computing in the project space. For more information, see Create a flow for data analysis.

Thank you! We've received your feedback.