- Introduction
- The Basic API
- Batch Processing
- Configuration Options
- Row and Column Separators
- Header Transformations
- Header Validations
- Data Transformations
- Value Converters
When you are importing data, it can be important to verify that all required data is present, to ensure consistent quality when importing data.
You can use the required_keys
option to specify an array of hash keys that you require to be present at a minimum for every data row (after header transformation).
If these keys are not present, SmarterCSV::MissingKeys
will be raised to inform you of the data inconsistency.
options = {
required_keys: [:source_account, :destination_account, :amount]
}
data = SmarterCSV.process("/tmp/transactions.csv", options)
=> this will raise SmarterCSV::MissingKeys if any row does not contain these three keys
PREVIOUS: Header Transformations | NEXT: Data Transformations