This section describes how to use import-csv.sh to import data in CSV format to IoTDB.
Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1 1,100,hello,200,300,400 2,500,world,600,700,800 3,900,"hello, \"world\"",1000,1100,1200
Before importing data, pay attention to the following:
./start-cli.sh -h Service IP address of the IoTDBServer instance node -p IoTDBServer RPC port
After you run this command, specify the service username as required.
SET STORAGE GROUP TO root.fit.d1; SET STORAGE GROUP TO root.fit.d2; SET STORAGE GROUP TO root.fit.p; CREATE TIMESERIES root.fit.d1.s1 WITH DATATYPE=INT32,ENCODING=RLE; CREATE TIMESERIES root.fit.d1.s2 WITH DATATYPE=TEXT,ENCODING=PLAIN; CREATE TIMESERIES root.fit.d2.s1 WITH DATATYPE=INT32,ENCODING=RLE; CREATE TIMESERIES root.fit.d2.s3 WITH DATATYPE=INT32,ENCODING=RLE; CREATE TIMESERIES root.fit.p.s1 WITH DATATYPE=INT32,ENCODING=RLE;
cd /opt/client/IoTDB/iotdb/tools
./import-csv.sh -h Service IP address of the IoTDBServer instance -pIoTDBServer RPC port -f example-filename.csv
Enter the service username and password in interactive mode as prompted. If information in the following figure is displayed, the CSV file is imported:
Run the following command to check the imported data:
SELECT * FROM root.fit.**;
If information in the following figure is displayed, the CSV file is imported.