CSV
CSV ingestion imports files into TDengine in two ways: file upload and monitoring a directory on the taosX host. This page uses a two-row temperature file to demonstrate parsing, mapping, and query verification for upload. The monitored directory belongs to the taosX host, not the browser host.
Entry point: taosExplorer → Data Ingestion → CSV. Execute SQL in the taosExplorer Data Browser or taos CLI.
Directory monitoring reads a directory on the taosX host and watches for new files. Before configuring it, upload a small file once to check parsing and writes.
1. Prepare a test file
| Item | Prerequisite |
|---|---|
| File location | For upload, the browser must be able to read the original file. In directory mode, the taosX process must be able to read the server input directory; also confirm mount paths in containers. |
| File content | Finished writing, UTF-8 encoded, with explicit header, delimiter/quote/comment characters, and time precision. Keep the original. |
| Directory permissions | Read and traversal permissions are required. If keeping processed files is disabled, deletion permission and data retention approval are also required. |
| Target objects | An independent database, supertable, and actual write identity. This page's graphical workflow maps supertables/child tables; it does not promise the same import support for regular tables. |
| Tools | taosExplorer and taos CLI for verification. Platform preparation commands use PowerShell and Bash respectively. |
Save the following as UTF-8 temperature.csv and keep the original. The times are millisecond timestamps within two seconds starting at 2026-11-20T00:00:00Z. If they fall outside target retention, update both the file and verification conditions together.
ts,device,temperature
1795132800000,d001,23.5
1795132801000,d001,24.5
Have an authorized TDengine TSDB administrator create independent target objects in the taosExplorer Data Browser or taos CLI:
CREATE DATABASE csv_demo PRECISION 'ms';
CREATE STABLE csv_demo.temperatures (ts TIMESTAMP, temperature DOUBLE)
TAGS (device VARCHAR(32));
2. Upload and import
- Add a CSV task and select
csv_demoas the target database. - Enable header inclusion, set the number of rows to skip to
0, the field delimiter to a comma, and the quote character to a double quote. This example has no comment lines; do not add extra skips. - In file upload mode, select
temperature.csvand enable Keep Processed Files to avoid deleting the server input copy after testing. The browser-selected file and uploaded server file are in different locations. - Click parse. Expect three header columns and two data rows. Parse
tsas milliseconds, temperature as numeric, and device as a tag. Use target supertabletemperatures, child table templatet_{device}, and no filter. - Preview, submit, and confirm the task has started. Record the runtime results.
Expand CSV Options. For this example, manually enable Has Header. The following figure shows a new form before entry. Initial values of header, file retention, and other switches do not replace this example's requirements.

Expand Payload Transformation, select Upload CSV File, and click Choose File. Multiple files with consistent formats can be selected at once. Upload Concurrency controls uploading, not file read concurrency or database write concurrency. Parse Rows controls the sample row count read during configuration. Its initial value 5 does not mean production import reads only five rows.

For this example, keep the original before uploading and manually enable Keep Processed Files. Confirm the filename and parsing settings, then click Parse. Check the recognized columns and two records, then complete mapping in the next section. Selecting a file alone does not submit a task.
2.1 Complete parsing and mapping
- Confirm the recognized columns are
ts,device, andtemperature, both device rows ared001, and temperature text is23.5and24.5. CSV content that looks numeric still needs conversion to the target type. Do not infer its type as if it were a JSON number. - Leave Extract or Split from Columns and Filter empty for this example. If the actual file also contains a
desc="zoneA,line1"column, ondesc, addsplit, delimiter,, and column count2, then previewdesc_0anddesc_1. Outer field quoting and inner splitting are separate steps. Do not add this rule if that column does not exist. - To filter by device, confirm the actual string type first. For example, to retain only this example's device, use
device == "d001". Previewd001and another device separately: retain the former and exclude the latter. Do not directly apply another connector's numeric field comparison expression to CSV strings. - Keep target database
csv_demo, select target supertabletemperatures, and use the field variable syntax supported by the page for the child table template to generatet_d001. At an entry point offering aformatexpression, entert_${device}. At an entry point using simplified templates, entert_{device}. Use the actual preview table name as the reference; do not mix the two input syntaxes. - Map source
tsas the primary timestamp in milliseconds, converttemperaturetoDOUBLE, and mapdeviceas a device tag. The preview must show the two expected records. Check advanced options and the error policy, submit, then find the original task in the list and confirm it has started.
After completing the two-row temperature exercise, see Extraction, splitting, filtering, and transformation and Target table modeling and field mapping for syntax when adding processing rules.
2.2 Example with splitting and filtering
The following figures use a different electric meter file with columns ts,current,voltage,phase,desc,id to illustrate the order of checks after parsing. Do not add its fields directly to the preceding temperature task. Dates in the figures are sample data. For actual imports, replace them with times within target retention and retain an explicit time zone.
- After clicking Parse, check the six columns and source values first. The comma-containing
descmust parse as one complete field rather than add an extra column. If the preview still contains unwanted quotes, correct file quoting and escaping before splitting.

- On
desc, addsplitwith delimiter,and count2, then check new columnsdesc_0anddesc_1. Splitting cannot repair CSV boundaries misidentified in the preceding stage.

- Filter expression
id != "1"excludes rows for device1. Other devices must remain in the preview. The comparison here uses CSV strings; later mapping a tag as an integer does not change the type at the filtering stage.

- Review the target model, then map time, values, descriptions, and device tags. Child tables expand as
csv_meter_${id}. The figure below retains a demonstration model withVARCHARvalue columns. If numeric calculations are required, use confirmed numeric columns and conversion rules. Do not reuse a string model merely because fields look numeric. Device names, times, and retained rows in the preview must agree with filter results.

These figures show the configuration process. They do not replace the two-row verification of the temperature exercise, and old sample dates or demonstration column types must not be copied directly into production models.
3. Switch to directory monitoring
The monitored directory must be an absolute path readable by the process on the taosX host, not a same-named directory on the browser host or in another container. Configure the matching regular expression to include only files that have finished writing. Write files outside the input directory first, then deliver them according to the agreed process to avoid reading incomplete files.
Under Payload Transformation, switch to Configure CSV Address and enter the File Monitoring Directory and matching pattern. This configures directory reads; it does not accept a web download URL. Other delivered UIs may call this tab Monitor File Directory. Use the actual control.

With Monitor New Files off, the task completes after processing initial files. With it on, the task keeps checking for new files and displays Monitoring Interval, in seconds, initially 30 in a new form. This controls checking frequency, not a single file's read timeout. File processing order depends on file sort settings, not record time order. Do not rely on filenames to guarantee record order across files. Disabling processed file retention may delete server input files. Confirm archival and recovery requirements before production use.

3.1 Check each parsing setting
| Option | Purpose | How to check |
|---|---|---|
| Has Header | Distinguishes field names from the first data record | Confirm the preview identifies ts, device, and temperature, rather than importing field names as data. |
| Skip First N Rows | Skips N CSV records after header processing | Does not first skip physical lines at the beginning of the file and then search for a header. Newlines inside quotes do not count as separate records; comments follow their prefix rules separately. |
| Field Delimiter | Splits record fields; , in the example | Use a single-byte character, not multiple characters. Check quoting when fields contain commas. |
| Field Quote | Encloses fields containing delimiters or newlines; " in the example | Must differ from the delimiter. Escape internal quotes according to CSV rules. |
| Comment Prefix | Skips comment records beginning with the specified character | Explicitly configure and preview # if needed. Do not assume an unconfigured direct DSN inherits the page default. |
| Nulls and conversion | Checks nulls, text markers, and numeric values | Source content is trimmed, and empty content becomes null. Text such as NULL requires a separate null marker. Do not assume matching text automatically becomes SQL NULL. |
Upload supports multiple files, but first ensure consistent formats and column meanings, and check processing for each file. For extraction, splitting, filtering, and mapping rules, see Extraction, splitting, filtering, and transformation and Target table modeling and field mapping.
For example, with header inclusion enabled for the temperature file above, a skip count of 0 should read both 23.5 and 24.5. Setting it to 1 additionally skips 23.5, leaving only 24.5. If explanatory lines precede the file header, do not increase the skip count expecting automatic discovery of the real header. First prepare and preview an input copy with a clear header, retaining the original. If the business needs leading/trailing whitespace preserved or empty strings distinguished from nulls, verify conversion results first as well.
Direct DSN parsing, read concurrency, null markers, and monitoring parameters are documented centrally in CSV read parameters. These are read-side options, not CSV export options. Configure UI upload concurrency and parse rows according to their own meanings.
3.2 Prepare the directory exercise
The following creates a new isolated directory on the taosX host. Stop if it already exists to avoid mixing in existing input. Do not change service permissions. If the creator and taosX service identities differ, obtain administrator approval for access first. File contents still use the two records above, without expanding the business object scope.
- Linux
- Windows
Run in Bash on the Linux taosX host. The directory in this example belongs to the current user; confirm service identity access separately:
set -e
input_directory="$HOME/taosx-csv-demo"
mkdir "$input_directory"
printf '%s\n' 'ts,device,temperature' \
'1795132800000,d001,23.5' '1795132801000,d001,24.5' \
> "$input_directory/temperature-001.csv"
ls -l "$input_directory"
printf '页面填写绝对路径:%s\n' "$input_directory"
Enter the command's absolute path output on the page. Do not enter $HOME directly and expect the service to expand it to the interactive user's directory. For taosX in a container, use its visible mount path, not a same-named host path directly.
Run in PowerShell on the Windows taosX host:
$inputDirectory = 'C:\taosx-csv-demo'
if (Test-Path -LiteralPath $inputDirectory) { throw '目录已存在,请使用新的测试目录。' }
New-Item -ItemType Directory -Path $inputDirectory -ErrorAction Stop | Out-Null
$csvContent = "ts,device,temperature`n1795132800000,d001,23.5`n1795132801000,d001,24.5`n"
[System.IO.File]::WriteAllText((Join-Path $inputDirectory 'temperature-001.csv'), $csvContent, [System.Text.UTF8Encoding]::new($false))
Get-ChildItem -LiteralPath $inputDirectory
The input directory on the page is C:\taosx-csv-demo, not the browser download directory.
Select the directory-read tab Configure CSV Address, enter the absolute path above and matching pattern temperature-[0-9]+\.csv$. Initially disable Monitor New Files, enable Keep Processed Files, and follow section 2 for parsing and mapping. After task completion and confirmation of both records, enable monitoring and deliver another set of data with new times under a new filename. Do not overwrite a same-named file while it is being read.
Directory scans first select lowercase .csv suffixes, then apply the matching pattern to filenames. If a file is named temperature-001.CSV or temperature-001.csv.gz, changing only the regular expression does not make directory scanning discover it. Deliver .csv files that follow the agreement first. Direct compressed-file reading and directory discovery are separate behaviors. One successful single-file read does not verify directory monitoring.
3.3 Subdirectories and order
Directory mode can include files in subdirectories. Paths separated by / are compared by depth first, with shallower files first; paths at the same depth are sorted case-insensitively. Ascending order sorts paths ascending, and descending order sorts paths descending, but descending order does not change the depth rule above. If Windows input paths or discovered paths use \, do not promise the same ordering across depths. Verify the actual directories first. For an exercise with strict ordering requirements, use a single-level directory initially. Unsorted mode uses discovery order, not a stable filename order.
Sorting determines the order of files awaiting reads. It does not guarantee the same completion order under concurrent processing or sort records within a file by time. If multiple files contain the same table and primary key, confirm that final updates meet business expectations even if filenames have an order. If strict order is required, have the task maintainer check read concurrency and delivery procedures, then verify with a small sample. Do not only adjust filenames.
4. Advanced options and write error policy
Before submitting, check batches and concurrency under Advanced Options. Establish a baseline with one file first. Concurrent completion order does not prove time order. Then check error actions, particularly null times, nulls in table name templates, column lengths, and automatic table creation. Archiving or discarding may leave fewer target rows than input rows. A file marked as processed does not replace target verification. Keep original input available; error archives are not complete file backups.

A new form initially sets maximum read concurrency to 0, determined by the reader, and batch size to 1000. Record these separately from upload concurrency, parse rows, and target write concurrency. Raising one does not establish higher overall throughput. When tuning, follow Tuning and resource control to compare identical file loads and target data results.
CSV read skip_error differs from target write error policies. Enabling skip_error permits unequal column counts: missing columns may be filled with nulls, extra columns do not automatically extend the model, and read errors may also be skipped. Do not enable it merely to finish the task or expect all skipped source content to appear in write error archives. Fix input formatting first, then verify against the source file inventory and target data.
For target error actions, defaults, and cache and archive settings, see Write errors. For viewing and extracting archives, see Logs and performance.
5. Verification
Run in the taosExplorer Data Browser or taos CLI:
SELECT ts, temperature, device FROM csv_demo.t_d001
WHERE ts IN (1795132800000, 1795132801000) ORDER BY ts;
Expect two rows with values 23.5 and 24.5, both for device d001. To verify directory monitoring, deliver a separate new file and confirm its target records, not just that the task remains running.
5.1 View task and per-file results
- Return to the Data Ingestion task list and locate the original task by the name and ID recorded at creation. Use Edit on the original task when changing the read scope. Copying creates another task and does not recover the original progress. For checks before starting, stopping, or deleting, see Daily operations.
- Click View for the task to open the metrics window. Cumulative Metrics shows retained historical totals; Current Run shows this round's processing. Confirm the run start before and after restarting. Do not directly subtract data from different runs.
- Switch to CSV File Processing Progress and compare each delivered file's path, start/end times, status, and processed row count. Paths belong to the file system visible to taosX. Uploaded copy paths may differ from original paths on the browser host.
- The first import on this page delivers only one two-row file. Find its path, confirm processing has ended, then run the SQL above to check both rows' times, values, and device tags. After enabling monitoring, check each separately delivered new file too. A continuously running task alone is insufficient.
| File status | Meaning and next step |
|---|---|
Not started (NotStarted) | The file is in the pending list. Check whether the task has started, earlier files remain, or concurrency is limited. Do not immediately upload it again. |
Processing (Processing) | Reading, processing, or waiting for downstream acknowledgment. If progress stalls, correlate logs, target writes, and timeout metrics in the table below. |
Completed (Completed) | Processing and acknowledgment for the file are complete. Still check filters, error actions, and target records. This does not mean every source row became a unique target row. |
Pending deletion (DeletePending) | Processing is complete, but deletion after disabling file retention has not succeeded. Check service identity and file locks first. Do not reupload written data merely to clear this status. |
Failed (Failed) | File processing failed. Keep the original and the first complete error. Confirm the completed scope before handling the file. |
The table also lists status identifiers to help compare wording across delivered UIs. The file list supports runtime Troubleshooting; it is not a permanent audit inventory for large imports. Retain a separate delivered-file inventory and verification records. With file retention enabled, completed files remain in the input directory as expected.
5.2 Interpret CSV metrics
| Metric | Purpose and interpretation |
|---|---|
total_csv_files, csv_files | Count distinct paths with saved progress or acknowledged data and increase as import advances. They are not the total files found in the initial directory scan. Use an external delivery inventory to detect missing files. |
csv_files_completed, csv_files_completed_rows | Files completed and rows processed during this run. When resuming from a checkpoint, they may count only remaining rows processed in this run, not all rows in the original file. |
total_csv_files_completed, total_csv_files_completed_rows | Saved cumulative completed files and rows. When a completed file is replaced, its old completion totals are deducted before processing. Values are not guaranteed to increase monotonically. |
csv_files_failed, csv_ack_timeouts | Counts of file failures or timeouts waiting for downstream acknowledgment. Read the file's logs first, then check formatting, file changes, and target writes. Do not only increase timeout values. |
csv_files_deferred, csv_files_skipped | Attempts deferred because files changed/disappeared or skipped because files were empty/header-only, for example. These are not counts of newly completed files. |
csv_files_delete_pending, csv_files_delete_failed | Pending or failed deletion counts in this run. Retry failures may make counts exceed file counts. Interpret them with individual file statuses and actual paths. |
For example, if the electric meter example reads ten rows and filters out two rows for device 1, eight target rows may be correct. Completed-file row counts need not equal target write counts in that case. Same-key overwrites, extraction and splitting, and error archiving also change this relationship. The earlier temperature exercise has no filter and still requires verification by its two specified primary keys and values. Do not substitute the other example's "eight rows".
Whether these fields appear in the UI or monitoring tables depends on the actual task and reporting. Missing fields or samples do not mean zero. For accessing the taosKeeper monitoring database and choosing instances and run windows, see Logs and performance. For cross-connector metrics, see Metrics dictionary and alert recommendations. If a file fails, do not reupload all files. First locate the failed path, acknowledged scope, and target results.
6. Troubleshooting and recovery
For incorrect column counts, first check the delimiter, quote character, and header setting. For incorrect times, check millisecond units and retention. If monitoring finds no new files, check the actual host, path permissions, and matching rules first. If preview shows two rows but the target does not, check field mapping.
Stop the original task and retain the processed inventory and input copies. An unexpected interruption may replay recent records whose progress was not yet durably saved. Replacing a same-named file may also trigger processing from the beginning; exactly-once writes are not guaranteed. Reuploading or recreating a task may reread files. First verify same-key write results in an isolated target. Do not "recover" by deleting input or clearing task state. CSV import does not restore database objects outside the files.
6.1 Legacy checkpoints and rereading after an upgrade
According to the v3.4.4.2 release notes, after a CSV directory-monitoring task is upgraded, it may reimport a file from the beginning if its legacy checkpoint cannot be validated under the new rules. For example, an incomplete legacy checkpoint without a verifiable file version produces a warning and rereads the file from the beginning. This does not mean that all legacy checkpoints or completed files are reread. For older versions, confirm whether the delivered version includes this change.
Before upgrading, stop the original task, preserve the original input files, task configuration, and checkpoint state, and record per-file progress and the primary keys, times, and values already written to the target. After upgrading, inspect legacy-checkpoint logs first, then check whether the reread range overlaps data already written. Use the source files and target unique primary keys to check for duplicates or overwrites. Do not delete originals or clear checkpoints merely to remove warnings. Confirm the boundaries before resuming processing of subsequent files.
For other task, write, and runtime issues, see Troubleshooting by symptom.