Formatting a CSV for Enum Import

From PHENOM Portal Knowledgebase
Jump to navigation Jump to search

To bulk import Enumerations and Enumeration literals, the CSV file should be formatted as described in this article.

General Column/Data Requirements

The following column headers must exist and contain data in each row:

  • Observable
  • Enum_Name
  • Literal_Name

The following columns are optional:

  • Enum_Description
  • Enum_Tags
  • Literal_Description
  • Literal_Tags

The order of the columns is not enforced, it does not have to be in the same order as the suggested format above.

Any additional user-made columns will be ignored and will not interfere with import.

Bulk import can currently import Enumerations and Enumeration Literals.

Column-specific Requirements

Observable

The specified Observable must exist in the model before import and be the correct realized Observable for existing Enumerations (see Platform Type and Enumeration for further detail).

Enum Name, Enum Description

Setting Enum_Name to an existing Enumeration will default to the first name-matched Enumeration within the model (there should only be one match).

When there is an existing Enumeration, the Enum_Name specified must realize the specified Observable. New Enumeration imports will automatically realize the specified Observable when they are saved.

Enum_Description is not a required field and can be omitted.

Literal Name, Literal Description

Literals belonging to different Enumerations may have the same name

Literal_Description is not a required field and can be omitted.

Tagging New Elements (Optional)

Optional columns can be added in to CSV to tag new Enumerations or new Enumeration Literals. Each field can have multiple comma delimited tags.

The raw CSV must have quotes around fields with commas (Excel normally handles this).

Enumerations and Enumeration Literals may share structure with other Enumerations/Enumeration Literals - keep this in mind when adding tags.

Additional Requirements

  • Data within Enum_Name and Literal_Name must begin with a letter, and only contain numbers, letters, or underscores. The data must also not match any of the following reserved words:
    • IDL Reserved words:

      "and", "begin", "break", "case", "common", "compile_opt", "continue", "do", "else", "end", "endcase", "endelse", "endfor", "endforeach", "endif", "endrep", "endswitch", "endwhile", "eq", "for", "foreach", "forward_function", "function", "ge", "goto", "gt", "if", "inherits", "le", "lt", "mod", "ne", "not", "of", "on_ioerror", "or", "pro", "repeat", "switch", "then", "until", "while", "xor"

    • OCL Reserved words:

      "abstract", "any", "attribute", "boolean", "case", "char", "component", "const", "consumes", "context", "custom", "default", "double", "emits", "Enumeration", "eventtype", "exception", "factory", "false", "finder", "fixed", "float", "getraises", "home", "import", "in", "inout", "interface", "local", "long", "manages", "module", "multiple", "native", "object", "octet", "oneway", "out", "primarykey", "private", "provides", "public", "publishes", "raises", "readonly", "sequence", "setraises", "short", "string", "struct", "supports", "switch", "true", "truncatable", "typedef", "typeid", "typeprefix", "union", "unsigned", "uses", "valuebase", "valuetype", "void", "wchar", "wstring"

  • New Enumerations not already within the model must be unique among elements of type View and IDLStruct.
  • If there are any errors during validation of the CSV file, the model import will not be initiated and a list of errors will be returned. They will be labeled by the row they occur on for convenience.
  • There is a 2MB limit in place - if a larger file needs to be imported, it needs to be split up into smaller files.
  • In the raw CSV (i.e., as observed from notepad), any field with commas must have surrounding quotes (Excel normally handles this).