Create a topic and upload data using the DataHub command line

Updated at:

This topic describes how to create a topic and upload data using the DataHub command line interface.

Procedure

  1. Download the DataHub console. For more information, see DataHub command line interface.

  2. Configure the console.

    1. Decompress and run the `datahub_console.tar` file.

    2. In the `conf` folder, edit the `datahub.properties` file to add your AccessKey ID, AccessKey secret, and endpoint information.90The parameters are described as follows:

      • datahub.accessid: The AccessKey ID that you use to access DataHub.

      • datahub.accesskey: The AccessKey secret that you use to access DataHub.

      • datahub.endpoint: The domain name. For more information, see the Domain Name List.

  3. Create a topic

    • -p: The name of the project.

    • -t: The name of the topic.

    • -m: The topic category. Set the value to `BLOB` to create a BLOB topic or `TUPLE` to create a Tuple topic.

    • -f: The field format for a Tuple topic. The format is `[(fieldName,fieldType,isNull)]`. If you specify multiple fields, separate them with commas.

    • -s: The number of shards.

    • -l: The time to live (TTL) for data, in days. The value must be an integer from 1 to 7.

    • -c: The description of the topic.

  4. Create the bank customer topic and modify the projectName.

    ct -p projectName -t bank_customer_1 -m TUPLE -s 1 -l 7 -c "Bank customer information" -f [(id,bigint,true),(id_number,string,true),(customer_name,string,true),(age,bigint,true),(gender,string,true),(mobile_phone_1,string,true),(date_of_birth,string,true),(education_level,string,true),(career,string,true),(marital_status,string,true),(salary,bigint,true),(monthly_transaction_amount,bigint,true),(monthly_transaction_count,bigint,true),(last_transaction_date,string,true),(family_annual_income,bigint,true),(current_deposit_balance,bigint,true)]
  5. Run the following command to upload data from the `data.csv` file. Replace `projectName` with the name of your project and specify the actual file path.

    • -f: The path of the file.

    Note

    On Windows, you must use double backslashes (\\) in the file path. For example, `D:\\test\\test.txt`.

    • -p: The name of the project.

    • -t: The name of the topic.

    • -m: The separator for text data. Commas and spaces are supported.

    • -n: The number of records in each batch for an upload. The default value is 1000.

    uf -f D:\\DataHubcmd\\data.csv -p projectName -t yhkh1 -m "," -n 10000