Read From CSV
Description
This activity Reads data from a specified CSV file.
Configuration
To configure the Read From CSV activity, click the Table Definition button in the activity's user interface to open the Table Definition dialog. Then, configure the following properties.
Table Definition dialog
In this dialog, you can manually add columns or use the auto-detection feature to identify column names and types if you have a sample CSV file.
You can define CSV-to-DataTable column mappings, select the appropriate .NET data type for each column, and specify formats for data types like DateTime based on your CSV file's structure.
Additionally, the dialog provides a Transformation option, enabling you to define expressions for transforming data while reading the CSV file. You can also create computed columns; for instance, if your CSV file contains FirstName and LastName columns, you can generate a FullName column using an expression like CSV_ROW["FirstName"] + " " + CSV_ROW["LastName"].
Auto detection – In the Auto Detect Settings dialog, specify the CSV file path for training.
- Set the number of rows to scan to detect each column's data type; by default, it scans 500 rows.
- If your CSV file includes column names in the first line, select the "First line represents CSV column names" checkbox.
- If auto-detection cannot determine a column's data type, it defaults the type to String.
- If the "First line represents CSV column names" option is unchecked, columns will be named Column1, Column2, Column3, … ColumnN.
Click the Preview button in the Table Definition dialog to preview your CSV data.
Properties
Input
- Delimiter– Specify the delimiter used in the CSV file, such as tab, comma(','), semicolon(';'), caret('^'), or pipe('|').
- Encoding – Specify the encoding type to use. The system sets the default encoding to UTF-8. For more details, refer to [Character Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding?vi
- File Path – Specify the path of the CSV file.
- Include Column Names – Specify whether the first row in the CSV file contains column names.
- Page Number – Indicate the page number to read from the file.
- Page Size – Define the number of rows to fetch per page.
- Read All – Enable this option to read all rows from the CSV file.
- Table Definition – Click the Table Definition button to open the corresponding dialog to define each column's data type and format.
Optional
- Continue On Error – Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False.
If you include this activity in Try Catch and the value of this property is True, it will catch no error during the execution of the project.
Misc
- DisplayName – Add a display name to your activity.
- Private – By default, activity will log the values of your properties inside your workflow. If private is selected, then it stops logging.
Output
- Data Table – The data read from the CSV file is written into DataTable.
- Total Rows – Total number of rows CSV file has.
Example
Download Example