Data Link — CSV
TTMSFNCDataLinkCSV loads CSV data into a TTMSFNCDataSet, enabling standard dataset operations (browse, filter, sort, bind) on CSV files without a database.
Key class: TTMSFNCDataLinkCSV
Loading a CSV File
Drop TTMSFNCDataLinkCSV on the form and either:
- Set the
FileNameproperty at design time — the file loads automatically. - Call
LoadFromFileorLoadFromStreamat runtime.
TTMSFNCDataLinkCSV1.FileName := 'data.csv';
// or
TTMSFNCDataLinkCSV1.LoadFromFile('data.csv', TEncoding.UTF8);
TTMSFNCDataLinkCSV1.LoadFromStream(MyStream, TEncoding.UTF8);
Link to a TTMSFNCDataSet:
TMSFNCDataSet1.DataLink := TTMSFNCDataLinkCSV1;
TMSFNCDataSet1.Active := True;
Separator Detection
| Property | Description |
|---|---|
AutoSeparator |
When True, auto-detects the field separator (comma, semicolon, tab, etc.) |
Separator |
Delimiter character used when AutoSeparator is False |
HasFieldNames |
When True, the first row is treated as a header row with field names |
Automatic Saving
Set AutoSaveChanges := True to persist modifications back to the file as they occur, without explicit save calls.
Methods
| Method | Description |
|---|---|
LoadFromFile(AFileName, AEncoding) |
Load from a file with the specified encoding |
LoadFromStream(AStream, AEncoding) |
Load from a stream |
SaveToFile(AFileName, AEncoding) |
Save to a file |
SaveToStream(AStream, AEncoding) |
Save to a stream |
Properties
| Property | Description |
|---|---|
AutoSaveChanges |
Auto-persist changes (default: False) |
AutoSeparator |
Auto-detect field separator |
FileEncoding |
Encoding for file operations |
FileName |
CSV file path |
HasFieldNames |
First row contains field names |
QuoteEmptyValues |
Enclose empty values in quotes when saving |
Separator |
Field delimiter when AutoSeparator is False |