Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

 

Description

Blob variables and attributes can be parsed to collections of object instances.

  1. Currently the parser only supports plain CSV files. Native Excel formats etc. are not supported.
  2. CSV files must have a single header line.
  3. Column names must match the attribute names as defined in the associated object type. For example an object’s first_name attribute will only be populated from the CSV file if the CSV file has a column with a header that is first_name Column headers that don’t match attributes from the associated object type will be ignored.
  4. 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.
  5. Any parsing errors will result in the entire transaction being rolled back. Detailed feedback to users in terms of where the parser failed is a work in progress.
  6. Complex attributes are supported. For example the CSV file may contain a column header clinic.name This will automatically populage 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 aren’t 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 access through a specific relationships is set to a non-null value, then that related object won’t be created.

Example code for extracting nurses from CSV in a blob type:

persistent object Clinic {
    string name;
}
 
persistent object Nurse {
    string first_name;
    date birth_date;
}
 
object UploadedFile {
    blob data;
}
 
Nurse[] extractNurses(UploadedFile f) {
    return Nurse:fromCsv(f.data);
}

 

Formatting CSV newline character files to Unix

CSV files created or manipulated using MS Excel are not compatible as is with Helium due to the carriage-return character excel uses (/r), to replace all /r chars with the standard Unix newline using the tr utility

The following will replace the carriage-return character into a new file

Unix newline
tr '\r' '\n' < helium-export.csv > helium-export.unix.csv

 

Additional Mentions and References

 

 

  • No labels