Ini (.ini)

Background & Context

    • Configuration file format.
    • Composed of sections.
    • Associates string keys to string values.
    • Stores configurations for operating systems and software.
    • Plain text format.

Import & Export

  • Import["file.ini"] returns a representation of an Ini file as an Association.
  • Import["file","Ini"] returns a representation of a file as an Ini file.
  • Import["file.ini",elem] returns the specified data representation of an Ini file.
  • Import["file",{"Ini",elem}] returns the specified data representation of a file.
  • Export["file.ini",expr] exports expr as a Ini file.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Data representation elements:
  • "Data"data as an association
    "DataRules"data as a list of rules
    "AnnotatedData"data as a list of sections as rules, and comments as strings
  • The Ini format exports elements of an association or a list.
  • "Ini" treats an association as a list of sections. The keys specify the section names; the values specify the elements of a section as associations. Expressions are converted to their input form string representation.
  • "Ini" accepts lists containing a mixture of rules and strings. Rules are exported as sections; strings are exported as commented lines.
  • A commented line starts with ";".

Examples

Basic Examples  (6)

Export an association as a section with properties:

Create a file:

Add a section and few properties to it:

Import it as an Ini file:

Create a file:

Write properties and comments to it:

Import the data only, as an Association:

Import the data and the comment:

Whitespace characters are not trimmed:

Sections must start with the character "[" and finish with "]":

Commented lines must start with the character ";":

Arbitrary expressions are converted to strings using InputForm:

Introduced in 2017
 (11.1)