IMD SolutionComputing LibraryShop main store

How-to

Edge historian CSV delimiter stays semicolon: stage and send it

Edge computing and IIoT Published 5 min read By IMD Solution engineering team

Short answer

No setting changes the export's semicolon delimiter, and a directive placed inside the FTP command is dropped. Stage the CSV yourself as a user file with the Excel separator directive on line 1, transfer it with a user-file export block descriptor, verify the received file, then delete the staged copy with ERASE because nothing purges the partition for you.

On this page
  1. Why the delimiter stays a semicolon
  2. Stage the file with the directive on line 1
  3. Send the staged file with a user-file descriptor
  4. Worked example: the 09:00 to 10:00 export at one row a minute
  5. Verify the received file before any erase
  6. Delete the staged copy on success
  7. Questions asked

Your edge device will keep writing semicolons: the history export's separator and file format are fixed, and there is no setting for either. A sep=; prefix placed inside the FTP command is discarded too, so the transfer itself can never carry it. The pattern that works is to stage the file yourself. A short BASIC action writes the Excel separator directive into a user file under the device's /usr partition and copies the history export in behind it, a user-file export block descriptor sends that file to the customer's FTP server, and ERASE removes the staged copy once delivery is verified. Here is the whole sequence, with the line-count arithmetic and the one data blemish to check before rollout.

Why the delimiter stays a semicolon #

Commit to this first: the separator and the export format are not configurable, so no setting turns the semicolon into a comma. The one inline trick worth ruling out is prefixing the directive inside the transfer. The tested form was:

PUTFTP "Example.CSV","sep=;"+Chr(13)+Chr(10)+"[dtHT$]"

The file that arrived held the export block's data and nothing else: everything in the source string except the block was discarded, so the directive never reached the server. The remaining manual fixes all push work onto the customer — hand-editing every file, a blanket find-and-replace that is unsafe because tag names may legitimately contain semicolons, or a Windows list-separator change. Staging the file on the device removes all three, and the same first-line directive is already the documented fix for a PLC data log that exports semicolon-delimited CSV, so the approach is established plant-floor practice.

Stage the file with the directive on line 1 #

A scheduled BASIC action builds the deliverable locally. This is the tested sequence:

MyAction:
HEADER$ = "sep=;"
T$ = Time$
DATETIME$ = T$(7 To 10)+T$(4 To 5)+T$(1 To 2)+"-"+T$(12 To 13)+"h"+T$(15 To 16)+"m"
FILENAME$="file:/usr/Data"+DATETIME$+".csv"
BLOCKNAME$ = "$dtHT $ftT $st_h1 $et_0"
OPEN FILENAME$ FOR TEXT APPEND AS 1
OPEN "exp:"+BLOCKNAME$ FOR TEXT INPUT AS 2
PUT 1, HEADER$
Loop:
TEMP$ = Get 2
PUT 1, TEMP$
IF TEMP$ <> "" THEN GOTO Loop
CLOSE 2
CLOSE 1
END

What each part does:

  1. HEADER$ holds the directive line that makes Excel split on semicolons.
  2. The Time$ slices reassemble the device clock's date and time fields into a stamp, so every run writes a fresh name — /usr/Data plus the stamp plus .csv — opened for text append as file 1. The run's hour and minute land after the dash, so a 10:00 run names its file with -10h00m in it.
  3. BLOCKNAME$ is the historical-data export block, windowed from one hour before the run ($st_h1) up to the run itself ($et_0).
  4. The exp: source opens that block as text input on file 2, and the loop copies it line by line until Get returns an empty string; the two CLOSE statements finish both files.

Send the staged file with a user-file descriptor #

A user file is addressed by its own export block descriptor form:

$dtUF$uf/usr/mycsvfile.csv

  1. Replace the example name with the staged file's actual path.
  2. Use that descriptor as the source of the FTP transfer, in place of the history block you were sending before.
  3. The transfer now ships the staged file as it sits — directive on line 1, history behind it — which the inline prefix could never do, because a whole file is sent rather than rebuilt from a block.

Worked example: the 09:00 to 10:00 export at one row a minute #

Inputs:

  • Export window: one hour back to the run time, from the block flags $st_h1 $et_0 in the tested action above.
  • Schedule: the action runs on the hour; this run is at 10:00 (example).
  • Logging: one tag stored once a minute (example input from the logger setup; the row count scales linearly with tags, and a deadband or event store would change it, so derive the count from your own logging configuration).
  • Line 1: the single directive line from HEADER$.

Rule in words: the staged file is the directive line followed by every line the export block returns, and the descriptor transfer copies it unchanged, so the received line count is predictable before anything is sent.

The arithmetic:

  • 60 minutes in the window × 1 stored row per minute × 1 tag = 60 history lines.
  • 60 history lines + 1 directive line = 61 lines expected on the server.
  • The row stamped exactly 09:00 can fall on either side of the window edge, so 62 lines is equally correct.

Result: at 10:00 the customer's server holds the staged file with the directive on line 1 and the hour's rows behind it, and Excel opens it split into columns with no operator step.

Decision: 61 or 62 lines with the directive on line 1 — run the erase step. Fewer than 61 lines, or anything else on line 1 — keep the staged file and resend before the next run adds another.

Verify the received file before any erase #

  1. Read line 1 of the received file: it must be the directive. Anything else means the descriptor pointed at the wrong path.
  2. Count the history lines against the window arithmetic above.
  3. Inspect the DateInt column in one staged file: the tested output carried a stray carriage return or line break there, cause not established. If the customer's tooling splits strictly on line breaks, prove a clean parse on that column before rollout.
  4. Confirm the columns split as intended. Once they do, the next complaint is usually display rather than data — why historian CSV timestamps show only the date in Excel covers it before the customer reports broken trends.

Delete the staged copy on success #

Nothing purges /usr automatically: the device does not drop the oldest user files when the partition fills, so a job without cleanup simply fills it. Once the checks pass, delete the staged file in BASIC with ERASE followed by its quoted path — the documented example form is ERASE "/usr/myfile.shtm" — substituting your staged CSV's path. Gate the erase on the verified transfer and keep the file on any failure, so a resend or a diagnosis still has it. An hourly push with built-in housekeeping is the same shape you already use to send PI historian CSV exports to an S3 bucket hourly, with the customer's FTP server in place of cloud storage.

Questions asked

Does the device ever clean old files out of its user partition?

No. Staged user files stay until something removes them, so an hourly export that never erases leaves 24 files a day and the partition only fills. Put the erase in the same scheduled action, gated on the verified transfer, and the partition holds one staged file at a time.

Is changing the Windows list separator a workable alternative?

Only for one machine and one user profile at a time: the list separator is a regional setting, so every new PC, every other CSV source and every user account needs the change again. For a customer who only opens these exports, the staged directive line does the same job with no housekeeping on their side.

Will parsers other than Excel understand the separator directive?

Do not rely on it. The directive is an Excel convention stored as plain text, so a script, database import or parser that does not recognize it reads line 1 as data. Reserve the staged file for humans opening it in Excel, and strip the first line before any automated ingest.

How often should the staging action run?

Match the schedule to the export window. The block used here reaches one hour back, so an hourly run keeps successive windows edge to edge: run it more often and rows repeat across files, run it less often and gaps open between windows. Change the window flags and the schedule together.

Keep reading

  • How-to

    Merge two historian servers' history blocks without tiering

    Yes — consolidate the two archives on one server by copying every history block that exists on only one server into the other's archive, repairing internal TagID lookup with the source taginfo.dat where names match but history stays missing, and moving any day both servers cover through CSV export and import. The destination should run the same historian release as the source or newer, 2017 or later.

    Edge computing and IIoT

  • How-to

    Backfilling trend history from a plant historian

    Yes, you can backfill trend history from a plant historian into a SCADA server. Extract the stored records through the historian's native export or ODBC interface, map each source point to its destination object with original timestamps and quality, insert the batches through the destination's documented history methods, and prove the import by reading the interval back from the destination. A saved CSV is a bridge, not proof of import.

    Edge computing and IIoT

  • Explainer

    Canary historian to Azure Blob Storage: the file path

    A Canary historian cannot connect to Azure Blob Storage as a database. The working path is an extraction job that reads tags through a documented interface, stages closed CSV files on a separate server, and uploads them outbound over HTTPS to a private container, one verified stage at a time.

    Edge computing and IIoT

What decides the historian trend average retrieval mode