The following applies to both methods of processing CSV files:
Currently, only plain CSV files are supported. Native Excel formats etc. are not supported.
CSV files must have a single header line.
In both cases the processing involves parsing a line of the CSV file to a DSL object instance. The following applies in this regard:
Column/header names for the CSV file must match the attribute names in the destination object. Case is ignored. A column firstname will, for example, match to attributes named both firstName and firstname.
Parsing is type-safe. For example, an object with a birth_date attribute that is of type date must contain values that can be converted to a date value using the acting user’s preferred Locale and Time Zone.
Complex attributes are supported. For example the CSV file may contain a column header clinic.name This will automatically populate the name attribute of an object that is associated with the primary object through a simple relationship with the name clinic. Simple relationships are one-to-one and many-to-one relationships. Other relationships are not supported and will be ignored. The object instance that represents the named relationships will only be created if the value in the column is not null. So if none of the complex attributes accessed through a specific relationships is set to a non-null value, then that related object won’t be created.
Any unhandled parsing errors related to CSV processing will result in the entire transaction involved being rolled back if the exception is not handled using the Helium exception handling mechanism. Details of the error can be inspected using the Helium logging service.
Standard CSV Processing
The standard CSV processing mechanism involves processing of an entire CSV file at once, resulting in a collection of object instances. This method makes use of the fromCsv built-in function.
For details on this method of CSV processing the following can be consulted:
The standard method of processing CSV files processes a whole CSV file at once using the fromCsv built-in function.
CSV Batch Processing
In addition to the standard method of CSV processing as mentioned above, Helium also provides a batch processing mechanism where each line in the CSV file is processed separately. The implication of this is that exception handling in Helium can be used to handle scenarios where parsing of a single line in the CSV file fails while still processing the remaining lines from the CSV.
This method of CSV processing makes use of the Mez:createBatch and fromCsvLinebuilt-in function as well as the MezBatch and MezBatchItembuilt-in objects.
For details on this method of CSV processing the following can be consulted:
Helium CSV batch processing processes a CSV file one line at a time using the Mez:createBatch and fromCsvLine built-in function and the MezBatch and MezBatchItem built-in objects.
Add Comment