ModMaster Manual v3.15 - D. CSV file format

Download manual: PDF HTML

D. CSV file format

This appendix describes the CSV file format used by the Export Registers, Import Registers, Export File Registers and Import File Registers items on the File menu (see Saving and restoring register definitions and Saving and restoring file register definitions ).

Files written by Export Registers and Export File 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","Min","Max","Write"
              

    for Export Registers and


          "File","Address","Name","Type","Value","Unit","Radix","Offset","Scale","Min","Max","Write"
              

    for Export File Registers.

  • 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" (for Export Registers only), "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", "float32" or "float64".

  • The Value, Scale, Offset, Min and Max fields contain values 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 and Import File Registers are fairly tolerant of the format of the files they 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 and Export File registers use.

  • The field names do not all have to be present. The only required field names are "Address" for Import Registers, and "File" and "Address" for Import File Registers. Default values will be provided for any missing fields.

  • The field names "File", "Address", "Name", "Type", "Value", "Unit", "Radix", "Offset", "Scale", "Min", "Max" and "Write" are recognized. "RW" is accepted as an alternative to "Write". Unrecognized field names, and their corresponding values, are ignored.

  • "discrete" and "disc/coil" are accepted as alternatives to "int1" in the Type field.

  • 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"'.

  • The Value, Scale, Offset, Min and Max fields must contain values in decimal.

  • Default values are provided for empty fields, except for the File and Address fields (which must contain values).

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