Skip to main content

Write CSV

Writes a data table to a CSV file

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Input

  • File Path - Path of the CSV file to write to.
  • Table - Data table to write to CSV file.

Options

  • Separator - Separator used in CSV file. Choose from Comma(,), Semicolon(;), TAB or Space.
  • Save with Encoding - Encoding used in CSV file. Choose from UTF-8, Windows 1250 to Windows 1258, ISO 8859-1 to ISO 8859-16, Macintosh and KOI8-R.
  • Headers - Whether to include headers in the CSV file or not. The default value is false.

How It Works

The Write CSV node performs the following steps:

  1. Validates Input - Ensures the input table is in valid data table format
  2. Checks File Path - Verifies the target file path is valid and writable
  3. Creates Directory - If the directory doesn't exist, creates the necessary folders
  4. Prepares Headers - If Headers option is enabled, extracts column names from the data table
  5. Formats Data - Converts data table rows into CSV format using the specified separator
  6. Applies Encoding - Encodes the data using the specified character encoding
  7. Writes File - Creates or overwrites the CSV file with the formatted data
  8. Closes Stream - Ensures the file is properly closed after writing

Requirements

  • File System Access - Write permissions to the target directory
  • Valid Data Table - Input must be a properly formatted Robomotion data table
  • Disk Space - Sufficient disk space to store the CSV file
  • Directory Path - Parent directory must exist or be creatable
  • File Permissions - If overwriting, the existing file must not be locked by another process

Error Handling

Error CodeDescriptionSolution
PERMISSION_DENIEDInsufficient permissions to write to the target locationCheck directory permissions and ensure write access
INVALID_TABLE_FORMATThe input table is not in valid data table formatVerify the table structure before writing
DISK_FULLInsufficient disk space to write the fileFree up disk space before retrying
INVALID_PATHThe file path contains invalid characters or formatVerify the path syntax is correct
FILE_IN_USEThe target file is locked by another processClose the file in other applications before writing
DIRECTORY_NOT_FOUNDParent directory doesn't exist and cannot be createdEnsure the parent directory path is valid
ENCODING_ERRORUnable to encode data with specified encodingTry a different encoding or check for incompatible characters

Usage Examples

Example 1: Export Data Table to CSV

Export processed data to a CSV file with headers:

Input:
- File Path: "C:\Exports\processed_data.csv"
- Table: myDataTable (contains processed records)
- Separator: Comma (,)
- Save with Encoding: UTF-8
- Headers: true

Result: Creates processed_data.csv with column headers and all data rows

Example 2: Create Report Without Headers

Generate a CSV report without column headers for legacy system import:

Input:
- File Path: "/home/user/reports/daily_summary.csv"
- Table: summaryData
- Separator: Semicolon (;)
- Save with Encoding: Windows 1252
- Headers: false

Result: Creates daily_summary.csv with only data rows, no header row

Example 3: Export International Data

Export data containing special characters with appropriate encoding:

Input:
- File Path: "D:\Data\customer_names.csv"
- Table: customerData (contains names with accents and special characters)
- Separator: Comma (,)
- Save with Encoding: UTF-16
- Headers: true

Result: Creates CSV file that properly preserves special characters

Usage Notes

  • Overwrite Behavior - Write CSV always overwrites the target file if it exists. Use Append CSV to add to existing files.
  • Header Source - Headers are automatically derived from data table column names when Headers option is enabled.
  • Encoding Selection - UTF-8 is recommended for modern systems. Use Windows-1252 for legacy Windows applications.
  • Separator Choice - Comma is standard for CSV. Use semicolon for European systems where comma is a decimal separator.
  • File Creation - The node creates the file and necessary parent directories if they don't exist.
  • Empty Tables - Writing an empty data table creates a CSV file with headers only (if enabled) or an empty file.
  • Data Type Conversion - All data is converted to strings during CSV writing. Numeric formatting is not preserved.

Tips

  • Always Use Absolute Paths - Specify complete file paths to avoid ambiguity about file location.
  • Test Encoding First - If unsure about encoding, test with a small sample first to ensure compatibility.
  • Backup Important Files - Since Write CSV overwrites files, backup important data before running.
  • Handle Errors Gracefully - Use Try-Catch blocks to handle file writing errors without stopping automation.
  • Verify After Writing - Use Read CSV immediately after to verify the file was written correctly.
  • Choose Appropriate Separators - If your data contains commas, consider using a different separator like semicolon or tab.
  • Memory Considerations - For very large data tables, monitor memory usage during write operations.
  • File Naming - Use timestamps in filenames for reports generated regularly (e.g., report_2025_01_15.csv).
  • Read CSV - Read CSV files back into data tables
  • Append CSV - Add rows to existing CSV files without overwriting
  • Split CSV - Split large CSV files into smaller chunks
  • Data Table - Learn about data table creation and manipulation
    • Create data tables programmatically