Clear DataTable
Clears all rows from a DataTable while preserving its column structure. This node is useful when you need to reset a table's data without recreating the entire table structure.
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.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Input
- Table - DataTable to clear all rows from
Output
- Table - DataTable with all rows cleared, but columns preserved
Behavior
- All rows in the table are removed
- Column structure remains intact (column names and count unchanged)
- The table becomes empty (0 rows)
- Original table object is modified and returned
Example Usage
Resetting a Table for Reuse
// Table has 100 rows with columns: ["ID", "Name", "Status"]
// Clear the table
// Result: Table with 0 rows, columns: ["ID", "Name", "Status"]
// Table structure is preserved and ready to receive new data
Clearing Data Before Processing
// Initialize a results table
var resultsTable = /* Create DataTable with columns */;
// Add some initial data
// ... Add Row nodes ...
// Before the next processing cycle, clear the table
// Clear DataTable node
// Result: Empty table ready for new batch of results
Conditional Data Reset
// Check if table needs to be reset
var needsReset = /* some condition */;
if (needsReset) {
// Clear all data while keeping structure
// Clear DataTable node processes this
// Populate with fresh data
// ... Add Row nodes ...
}
Reusing Tables in Loops
// Create a temporary table for processing
var tempTable = /* Create DataTable */;
// Process multiple data batches
for (var batch = 0; batch < batches.length; batch++) {
// Clear previous batch data
// Clear DataTable node
// Process current batch
for (var i = 0; i < batches[batch].length; i++) {
// Add Row to tempTable
}
// Do something with tempTable
// Export, analyze, etc.
}
Tips
- Use this node when you want to reuse a table structure without recreating it
- More efficient than creating a new table when the column structure remains the same
- Useful in loops where you process data in batches
- The column structure (names and order) is completely preserved
- All row data is removed - this operation cannot be undone
- Consider backing up important data before clearing
Common Errors
Empty Table Error
Error: Table cannot be empty. Please provide a valid DataTable.
Solution: Ensure you're passing a valid DataTable object from a previous node.
// Wrong - table is null or undefined
var table = null;
// Correct
var table = /* Valid DataTable from Create DataTable or other source */;
Clearing an Already Empty Table
Clearing an already empty table is not an error - it simply results in the same empty table. This is safe to do.
// Table with 0 rows
// Clear DataTable
// Result: Table with 0 rows (no change, no error)
Difference from Create DataTable
-
Clear DataTable: Removes rows from existing table, keeps columns
- Input: Existing table with data
- Output: Same table structure, no rows
-
Create DataTable: Creates brand new table structure
- Input: Column names
- Output: New empty table
Use Clear DataTable when you want to preserve the table instance and just remove data. Use Create DataTable when you need a fresh table object.
See Also
- Create DataTable - Create a new empty table
- Remove Row - Remove specific rows
- Add Row - Add rows after clearing
- Filter DataTable - Keep only matching rows