tree: a13834999145e13a0a20c5e68006c097789bf71b [path history] [tgz]
  1. src/
  2. pom.xml
  3. README-zh.md
  4. README.md
java/tools/README.md

English | Chinese

TsFile Tools Manual

Introduction

Development

Prerequisites

To build the Java version of TsFile Tools, you must have the following dependencies installed:

  1. Java >= 1.8 (1.8, 11 to 17 are verified. Make sure the environment variable is set).
  2. Maven >= 3.6 (if you are compiling TsFile from source).

Build with Maven

mvn clean package -P with-java -DskipTests

Install to local machine

mvn install -P with-java -DskipTests

schema 定义

ParameterDescriptionRequiredDefault
table_nameTable nameYes
time_precisionTime precision (options: ms/us/ns)Noms
has_headerWhether it contains a header (options: true/false)Notrue
separatorDelimiter (options: , /tab/ ;)No,
null_formatNull valueNo
id_columnsPrimary key columns, supports columns not in the CSV as hierarchyNo
time_columnTime columnYes
csv_columnsCorresponding columns in the CSV in orderYes

Explanation:

The “id_columns” sets values in order and supports using columns that do not exist in the CSV file as levels. For example, if the CSV file has only five columns: “a”, “b”, “c”, “d”, and “time”, id_columns a1 default aa a Among them, a1 is not in the CSV column and is a virtual column with a default value of aa

The content after csv_columns is the definition of the value column, with the first field in each row being the measurement point name in tsfile and the second field being the type When a column in CSV does not need to be written to tsfile, it can be set to SKIP.

Example: csv_columns Region TEXT, Factory Number TEXT, Device Number TEXT, SKIP, SKIP, Time INT64, Temperature FLOAT, Emission DOUBLE,

Data Example CSV file content:

sample data

CSV file content:

Region,FactoryNumber,DeviceNumber,Model,MaintenanceCycle,Time,Temperature,Emission
hebei,1001, 1,10,1,1,80.0,1000.0
hebei,1001,1,10,1,4,80.0,1000.0
hebei,1002,7,5,2,1,90.0,1200.0

Schema definition

table_name=root.db1
time_precision=ms
has_header=true
separator=,
null_format=\N


id_columns
Group DEFAULT Datang
Region
FactoryNumber
DeviceNumber

time_column=Time

csv_columns
RegionTEXT,
FactoryNumber TEXT,
DeviceNumber TEXT,
SKIP,
SKIP,
Time INT64,
Temperature FLOAT,
Emission DOUBLE,

Commands

csv2tsfile.sh --source ./xxx/xxx --target /xxx/xxx --fail_dir /xxx/xxx 
csv2tsfile.bat --source ./xxx/xxx --target /xxx/xxx --fail_dir /xxx/xxx