Modsak Manual - Appendix C. CSV file format

Appendix C. CSV file format

This appendix describes the CSV file format used by the FileExport Registers and FileImport Registers menu items (see Saving and restoring register definitions ).

Files written by Export Registers follow these rules:

  • Each line of the file consists of comma-separated fields.

  • Each line contains the same number of fields.

  • Each field is enclosed in double-quotes.

  • A double-quote within a field is represented by two consecutive double-quotes. For example, the string '"Real" pressure' would be written as:


          """Real"" pressure"

  • The first line of the file is a header line containing the names of the fields:


          "Address","Name","Type","Value","Unit","Radix","Offset","Scale","Write"
              

  • Each subsequent line contains the values for a register, e.g.:


          "3049","Alarm 4","int16","0","","10","0.0","1.0","false"
          "3058","New data flag","int16","0","","10","0.0","1.0","true"
              

  • Each Type field contains "int1", "int8", "int16", "int32", "int64", "float32" or "float64".

  • Each Value field contains the register value in decimal.

  • Each Write field contains "true" or "false".

  • There are no space characters in the file, except within double-quotes when the field value is a string that contains spaces.

  • UTF-8 character encoding is used.

Import Registers is fairly tolerant of the format of the files it will read:

  • The first line of the file must be a header line containing the names of the fields.

  • The field names do not have to be in the same order that Export Registers uses.

  • The field names do not all have to be present. The only required field name is "Address"; default values will be provided for any missing fields.

  • The field names "Address", "Name", "Type", "Value", "Unit", "Radix", "Offset", "Scale" and "Write" are recognized. Unrecognized field names, and their corresponding values, are ignored.

  • Case is not significant in field names.

  • Subsequent lines in the file must contain register values corresponding to the fields named on the first line.

  • Double-quotes are only necessary around fields that contain commas or double-quotes, or that have leading or trailing spaces.

  • Blank lines and lines that start with '#' are ignored.

  • Leading and trailing space characters in fields are ignored (except within double-quotes).

  • The Unix style of escaping using backslash is accepted in fields that are not enclosed in double-quotes. For example, the field:


          Pressure\, \"Real\"
              

    would be read as 'Pressure, "Real"'.

  • Each Value field must contain the register value in decimal.

  • Default values are provided for empty fields, except for the Address field (which must contain a value).

  • UTF-8 character encoding is assumed. ASCII is accepted, since it is a subset of UTF-8.