ini2csv

Index Home MAE > MAE Architecture > MAE Utilities > ini2csv

ini2csv

This command converts an INI file into CSV or SQL statements.

The command syntax is:

ini2csv [-a] [-sql] [inifilename]

where,

Option

Description

-a

Specify the app's name for inclusion in the output. If not provided, the base INI filename is used instead, e.g. mapedit for mapedit.ini.

-sql

Generate SQL statements (not CSV). Note that the first SQL line output is a DELETE statement to remove all existing records from table Property for the app named.

inifilename

The filename containing INI data to be converted. If none provided, then input is taken from stdin with the default application name of stdin.


INI File Format

An INI file is a file of properties, organized into sections for an application.

The format is line oriented.

Comment lines begin with # or semicolon.

A line with a term in square brackets begins a new section of key/value pairs. Before the first section, the implied section name is global.  For example,

[ui]

Inside a section, key/value assignments are listed.  For example,

   max_users = 50

   greeting= Welcome to the app!

There is no limit on the number of sections provided or the number of key/value assignments per section.

General format:

       ; this is a comment

       # this is a comment

       [section]

       variable1=numvalue

       variable2=textvalue \

               moretextvalue

CSV File Format

The first line of output is the headers:

AppName,Section,Variable,Value

where,

Header

Description

AppName

The name of the application for these properties.

Section

The section (grouping) of the application for these properties.

Variable

The keyword for the property.

Value

The value of the property.


Example CSV output file:

   AppName,Section,Variable,Value

   "mapedit","ui","max_users",50

   "mapedit","ui","greeting","Welcome to the app!"

SQL Table Schema

The SQL generated modifies the table named Property, which must have at least these four fields:

Header

Type

Description

AppName

text

The name of the application for these properties.

Section

text

The section (grouping) of the application for these properties.

Variable

text

The keyword for the property.

Value

text

The value of the property.


Example SQL output file:

DELETE FROM Property WHERE AppName="mapedit";

INSERT INTO Property (AppName,Section,Variable,Value) VALUES("mapedit","ui","max_users",50);

INSERT INTO Property (AppName,Section,Variable,Value) VALUES("mapedit","ui","greeting","Welcome to the app!");

See Also

Class IniFile