A data source which will deliver CSV data (comma separated values) to your templates, razor, tokens or WebAPI / JSON.
This is what it looks like in the Visual Query Designer
Streams in the CsvDataSource DataSource
- In - non expected
- It expects no In-Streams. If you add any, you could use that for parameters, but this is an uncommon scenario
- Out - Default only
- Default - containing the list of items in the CSV file
Configuration of the CsvDataSource
- File Path - a path based on the root of the web-server, like /Portals/0/Sync/MyProducts.csv or /App_Data/Sync/ERP-Export.csv
- Delimiter - this can be a comma, semi-colon, tab or anything. If you want to add a tab, best create one using Microsoft-Word and copy-paste it into the field. You can also leave this blank, then a tab will be assumed.
- Content-Type Name - an internal name like "CsvProducts" or something - not relevant for most use cases
- Id-Column Name - leave blank to auto-number each item based on the CSV-rows; if you have a number-field which marks each item in the CSV like PRODUCTID or something, I would use that. Note that it's case sensitive.
- Title-Field Name - the title field. Leave blank to just use the first column in your CSV if you don't care about the exact field. Case sensitive.
Note that in all these cases you can also use Tokens for parameters. For example
- you could say the file should be /App_Data/Sync/[DateTime:Now|yyyy-mm]/export.csv to use year-month in your path.
- you could also place the file in App-Settings so that your editor can change it - then your file would just come from [App:Settings:ProductSyncFile] or similar
Special Behavior of the CsvDataSource
CSV is one of the oldest file formats - but it still is not fully standardized. We're using a CSV Framework called CSVHelper for this job which takes care of many things, but we're assuming each value is a string-value to prevent too many bugs when reading the CSV file. So you'll probably want to do some re-formating in your template for dates and similar stuff.