![]() | InDesign SDK 20.5 |
#include <DataUpdaterCSVFileHelper.h>
Public Member Functions | |
| DataUpdaterCSVFileHelper () | |
| virtual | ~DataUpdaterCSVFileHelper () |
| ErrorCode | Load (const IDFile &file) |
Public Attributes | |
| K2Vector< WideString > | fKeys |
| K2Vector< WideString > | fFields |
| K2Vector< WideString > | fValues |
| WideString | fTableName |
| PMString | fFileName |
From SDK sample; DataUpdaterCSVFileHelper is a helper class for handling CSV files.
A naming convention has been adopted for CSV filenames so you can have several files within the same folder that give values for the same table of data. The naming convention is:
Table[_Qualifier][.csv]
where:
[] - optional
So Inventory_Apr.csv and Inventory_May.csv, would all specify values from the same table of data "Inventory".
For example consider the file "Inventory_Apr.csv" with contents:
SKU, Price, Description
A175, ?0, Electric Drill
B456, ?, Hammer
A767, ?, Screwdriver
The first line contains the names of the fields in the file. These are loaded into the fFields member. The first column contains the key for each record and must be unique. These are loaded into the fKeys member. All values, including keys, are loaded into the fValues member.
Note that all the values from the CSV file are cached in this class.
| DataUpdaterCSVFileHelper::DataUpdaterCSVFileHelper | ( | ) |
Constructor.
| virtual |
Destructor.
| ErrorCode DataUpdaterCSVFileHelper::Load | ( | const IDFile & | file | ) |
Load the given CSV file.
| file | CSV file containing data to be loaded. |
| K2Vector<WideString> DataUpdaterCSVFileHelper::fFields |
Fields in the first line of the CSV file are loaded here. The first line contains the names of the fields in the file.
| PMString DataUpdaterCSVFileHelper::fFileName |
The CSV file name.
| K2Vector<WideString> DataUpdaterCSVFileHelper::fKeys |
The first field per line in the CSV file is loaded here. This field contains the key for the CSV file record and should be unique in the CSV file.
| WideString DataUpdaterCSVFileHelper::fTableName |
The name of the table the CSV file represents derived from the CSV file naming convention described above.
| K2Vector<WideString> DataUpdaterCSVFileHelper::fValues |
All fields in the second and subsequent lines of the CSV file are loaded here.