Data Transforms
Bulk edit the dataset before pushing it to your system.
The Data Transforms feature in CSVbox empowers you to modify and manipulate the data before it is uploaded to your app. Using JavaScript, you can apply custom transformations to reshape, sanitize, or enhance your data in real-time. Whether you need to perform simple tasks like capitalizing text or formatting dates, or handle complex business logic, Data Transforms gives you full control to customize your dataset to meet your app's specific needs.

How it works
When a CSV file is uploaded, CSVbox parses the data and applies your transformation logic row-by-row or column cell-by-cell. The JavaScript function you write defines how each row or field should be transformed. Once the transformation is complete, the modified data is passed to the next stage for validation. There are two main types of Data Transforms available in CSVbox: Row Transforms and Column Transforms.
Row Transforms apply transformation logic row-by-row, processing each row individually from top to bottom. These are especially useful when the transformation of one cell depends on the values of other cells within the same row. For instance, if you need to combine data from multiple cells into a single cell, or if a calculation requires input from different columns within the same row, Row Transforms are ideal. This approach allows you to apply logic dynamically based on relationships within each row of data.
Column Transforms operate on a single column or a set of selected columns, applying transformations to all entries in the specified columns at once. These transforms are most effective when you need to analyze or modify data across the entire column rather than row-by-row. For example, if you're looking to identify duplicate entries in a column and replace each duplicate with a unique identifier, a Column Transform can help by analyzing all values in that column collectively before applying changes. This approach is efficient for transformations that rely on examining the column as a whole, such as sorting, aggregating, or deduplication tasks.
Using these two transformation types, you can precisely target and manipulate your data based on your application's requirements, whether you need to perform intra-row calculations or make adjustments to column-wide data sets.
Selecting Column Transforms can impact importer performance, as the entire column dataset is loaded into memory for processing. This means that, especially with large datasets, using Column Transforms may slow down the import process. For optimal performance, consider using Row Transforms for operations that do not require analyzing the entire column, reserving Column Transforms for cases where column-wide data processing is essential, such as deduplication or aggregation tasks.
Row Transforms
Adding Row Data Transforms
Go to the edit sheet page > Data Transforms tab > Click Add Transforms button.
Add Transform Name.
Select Transform Type as Row.
Provide Javascript code.
Attach Dependent Libraries (optional).
Click Save.
Row Transform Examples
Append a constant to the cell value.
Normalize date value into US format.
Variables in the Row Transform
You have access to data variables included in the csvbox object. The following data is available:
csvbox.row
csvbox.rowIt contains row data. Each cell in the row can be accessed by providing the column name. Examples:
csvbox.user
csvbox.userIt contains the custom user attributes defined while initializing the importer. Examples:
csvbox.import
csvbox.importThis refers to the current import-specific data. The following data is available:
csvbox.columns
csvbox.columnsThis object contains the column metadata (name, type).
csvbox.environment
csvbox.environmentIt contains the environment variables that are passed during importer initialization.
Column Transforms
Adding Column Data Transforms
Go to the edit sheet page > Data Transforms tab > Click Add Transforms button.
Add Transform Name.
Add the Columns you need for the transform.
Provide Javascript code.
Attach Dependent Libraries (optional).
Click Save.
Column Transform Examples
Capitalizing Text Fields:
Variables in the Column Transform
You have access to data variables included in the csvbox object. The following data is available:
csvbox.column
csvbox.columnIt contains the entire column data. Each cell in the column can be accessed by providing the column name and the row number. The row number starts with 1. Examples:
Only the selected columns will be available in the Transform javascript.
csvbox.user
csvbox.userIt contains the custom user attributes defined while initializing the importer. Examples:
csvbox.import
csvbox.importThis refers to the current import-specific data. The following data is available:
csvbox.environment
csvbox.environmentIt contains the environment variables that are passed during importer initialization.
csvbox.columns
csvbox.columnsThis object contains the column metadata (name, type).
console.log(csvbox);
Dependencies
In the Transforms Javascript snippet, you can utilize an external library hosted via a CDN. You can also call any external API endpoint to fetch real-time data. Add the library script tag and/or any custom scripts to the 'Dependencies' section and use it in the main Javascript snippet.
Execution Time
Every Data Transform can now run at one of two stages in the import pipeline:
Pre Data Validation (default)
Post Data Validation
This gives you full control over when your transform runs during the import workflow.
1. Pre-Validation Data Transform
Runs immediately after column mapping and before Data Validation.
Use this for:
Cleaning or normalizing user input
Converting formats (dates, numbers, booleans)
Combining or splitting fields
Setting defaults
Preparing data that validators depend on
Example:
Convert a string such as " 23.4500 " into a clean numeric value before your validation rules run.
2. Post-Validation Data Transform
Runs only if there are no validation errors, and just before pushing data to the final destination.
Use this for:
Final formatting
Destination-specific transformations
Generating or enriching fields only when the row is already valid
Preparing computed values needed only for storage
Example:
If you need to generate a slug, UUID, or apply pricing markup after all validations pass.
Where to Configure Execution Time
When creating or editing a Data Transform:
Open Sheet Settings → Data Transforms.
Select your existing transform or create a new one.
Choose the desired Execution Time:
Pre Data Validation
Post Data Validation
Save your changes.
Key Features
JavaScript-Powered: Write custom JavaScript code to perform operations on your data. With access to native JavaScript methods, you can implement transformations ranging from basic modifications to complex logic.
Real-Time Execution: Your transformations are applied as the file is uploaded, ensuring that the data is processed and adjusted before it enters your app.
Versatile: Use Data Transforms to handle a wide range of operations, such as:
Modifying string data (e.g., capitalizing text, trimming spaces)
Formatting dates
Performing calculations, such as currency conversions
Validating and cleaning up data
Applying conditional logic to data fields
Error Handling: You can include custom error handling in your JavaScript to manage issues gracefully without disrupting the upload process.
Best Practices
Error Handling: Incorporate error-handling logic into your JavaScript code to avoid disruptions in the upload process due to malformed data.
Optimize Performance: Keep your transformation code efficient, especially when working with large datasets, to ensure smooth uploads.
Conclusion
With Data Transforms, you have the flexibility to clean, format, and manipulate data in real-time as it's uploaded through CSVbox. Whether you need to perform simple formatting tasks or implement complex business logic, Data Transforms can help you streamline your data handling processes and ensure that your datasets are always consistent and accurate.
Last updated
Was this helpful?