
Skill
tsfile-cli
inspect and manage Apache TsFiles
Description
Use when you need to inspect, preview, export, OR import an Apache TsFile (.tsfile) from the command line — list devices/tables, dump schema, read file/series metadata, count rows, sample/preview rows, or write CSV/TSV into a new .tsfile — via the project's C++ `tsfile-cli` in cpp/tools.
SKILL.md
tsfile-cli
Single pipe-friendly C++ binary to inspect and import .tsfile (TsFile's analogue of
parquet-cli/pqrs). Source cpp/tools/. Read data → stdout, diagnostics → stderr;
write imports CSV/TSV → a new file.
Scope
Use this skill for command-line builds and operations. For Java, Python, C++,
or C SDK integration, schema design, and programmatic tree-model writes, load
the sibling tsfile skill at ../tsfile/SKILL.md.
Binary
- Name
tsfile-cli(CMake targettsfile_cli). Find:ls cpp/build/*/bin/tsfile-cli. - Build only if missing:
cd cpp && bash build.sh -t=Debug.
Read
tsfile-cli <cmd> [opts] <file.tsfile> · tsfile-cli --help | --version | help
| cmd | output | scans pages |
|---|---|---|
ls | device (tree) / table (table) per line | no |
schema | target,measurement,datatype,encoding,compression | no |
meta | model, device/table/series counts, time range, size | no |
stats | per-series count,start,end,min,max,first,last,sum | no |
count | per-series counts + total row | no |
head | first N rows (default 10, -n) | yes |
cat | all matching rows (streamed; table format buffers) | yes |
sample | reservoir sample (default 10, -n + --seed) | yes |
Prefer no-scan verbs (ls/schema/meta/stats/count) — cheap and never hit the page-decode caveat.
Table model + row verbs (head/cat/sample): without -t, only the first table is queried. Pass -t <table> to target a specific one (count covers all tables).
opts: -f csv|tsv|json|table (default TTY→table, pipe→tsv)
-d <device> | -t <table> (mutually exclusive)
-m a,b,c (projection) · -n N · --offset N · --start <ms> · --end <ms> (inclusive)
--tag-filter C OP V · --tag-between C L U · --tag-not-between C L U (table TAG predicates)
--seed N · --no-header · --model tree|table (else auto)
applies: -m → schema/stats/count/head/cat/sample · -d/-t → row cmds/schema/stats/count
(-d needs tree model, -t needs table model in head/cat/sample/schema) · --offset ∉ sample
tag filters → head/cat/sample table model; OP=eq|neq|lt|lteq|gt|gteq|regexp|not-regexp
json=NDJSON (num/bool bare, else quoted, null→null, NaN/Inf→null) · csv=RFC4180 · ts=raw epoch ms
exit: 0 ok · 1 usage · 2 file open/corrupt · 3 query/runtime
The aligned table format buffers rows. Prefer csv, tsv, or json for
large dumps and pipelines.
B=cpp/build/Debug/bin/tsfile-cli
$B meta data.tsfile; $B count -t table1 -f tsv data.tsfile
$B cat -t table1 --tag-filter device eq dev_1 -m temp -f tsv data.tsfile
$B cat -m temp --start 1700000000000 -f csv data.tsfile 2>/dev/null | head
Write
tsfile-cli write --table <name> --columns <spec> -o <out> [-f csv|tsv] [--no-header] [--header-match] [-v] [<input> | -]
Imports rows into a new table-model file (overwritten). Input col 0 = timestamp
(epoch ms, int); remaining cols declared by --columns — no type inference.
spec := col (',' col)*
col := name ':' TYPE ':' ('tag' | 'field') # TYPE + category case-insensitive
TYPE ∈ { BOOLEAN, INT32, INT64, FLOAT, DOUBLE, STRING, TEXT, TIMESTAMP, DATE, BLOB }
input := file | '-' | omitted # '-' or omitted = stdin
-orequired (overwritten, must differ from input);-fdefault csv (json/table → usage error).- header: first line skipped by default ·
--no-headerif none ·--header-matchvalidates header names vs--columns(mutually exclusive with--no-header). - empty cell = null ·
--tableis lower-cased ·DATEcells areYYYY-MM-DD,TIMESTAMPepoch ms · each column stored with the engine default encoding/compression for its type · success silent,-v→ echoes the resolved config +wrote N rows to <out>on stderr. - timestamps must be strictly increasing per device (device = tag-column values); rows for different tags may interleave/reuse timestamps. Out-of-order input → error with line number.
- a failed import deletes its partial output (no half-written
.tsfileleft behind). - exit:
1usage (missing--table/--columns/-o, bad spec, dup column, read-only flag) ·2IO open ·3row (field-count / type / overflow / timestamp-order / header mismatch).
printf 'time,id1,s1\n0,dev,0\n1,dev,10\n' \
| tsfile-cli write --table t1 --columns "id1:STRING:tag,s1:INT64:field" -o out.tsfile -
tsfile-cli count -f tsv out.tsfile # -> t1.dev s1 2
Tree-model / JSON / programmatic writes → C++ SDK cpp/examples/cpp_examples/demo_write.cpp
(TsFileTableWriter/TsFileWriter + Tablet); Java/Python writers under java/, python/.
Caveats
head/cat/sampledecode pages → may abort (decode_cur_time_page_data, exit 134) on some aligned files incl. bundledcpp/examples/test_cpp.tsfile. Storage-engine/file issue, not a CLI bug; metadata verbs still work. Use a well-formed (e.g. self-written) file for rows.- table-model
targetis derived from tag bytes → may show non-printable chars instats/count/schema. schemalists all columns;meta/stats/countcount only field series →series_countcan be fewer thanschemarows (not a bug).
More skills from the tsfile repository
View all 2 skillsMore from Apache Software Foundation
View publisherComputer Use
operate local desktop applications
maka
Aug 20AutomationDesktopMCPdatafusion-python
write Apache DataFusion Python code
datafusion-python
Jul 12Data AnalysisPythonSQLflink-agents-dev
build and debug Apache Flink agents
flink-agents
Aug 7AgentsAutomationMCPbydbql
generate and execute BanyanDB BydbQL queries
skywalking-banyandb
Jul 12AnalyticsDatabaseSQLcompiling
compile and build BanyanDB projects
skywalking-banyandb
Jul 12BuildEngineeringgh-pull-request
create GitHub pull requests for BanyanDB
skywalking-banyandb
Jul 12GitHubPull Requests