INI Format
Description
INI (Initialization) format is a simple configuration file format used for storing application settings. It supports sections (marked with [section]) and key-value pairs. The format is also used for properties files (without sections).
File Extensions
.ini- INI configuration files.properties- Properties files (alias).conf- Configuration files (alias)
Implementation Details
Reading
The INI implementation:
- Uses Python's
configparsermodule - Supports sections and key-value pairs
- Handles properties files (no sections)
- Converts sections to records with
_sectionfield - Falls back to simple key=value parsing if configparser fails
Writing
Writing support:
- Writes INI format with sections
- Supports key-value pairs
- Can write properties format (no sections)
Key Features
- Section support: Handles INI sections
- Properties format: Also supports properties files
- Simple format: Easy to read and write
- Configuration files: Designed for application configuration
Usage
from iterable import open_iterable
# Basic reading
source = open_iterable('config.ini')
for row in source:
print(row) # Each row has _section and key-value pairs
source.close()
# Writing
dest = open_iterable('output.ini', mode='w')
dest.write({'_section': 'database', 'host': 'localhost', 'port': '5432'})
dest.close()
Parameters
encoding(str): File encoding (default:utf8)
Limitations
- Simple format: Limited to key-value pairs
- No nested structures: Doesn't support complex nested data
- Type handling: All values are strings
- Section handling: Sections are converted to
_sectionfield
Compression Support
INI files can be compressed with all supported codecs:
- GZip (
.ini.gz) - BZip2 (
.ini.bz2) - LZMA (
.ini.xz) - LZ4 (
.ini.lz4) - ZIP (
.ini.zip) - Brotli (
.ini.br) - ZStandard (
.ini.zst)
Use Cases
- Configuration files: Application and system configuration
- Properties files: Java-style properties files
- Settings storage: Storing application settings
- Simple config: When you need simple key-value configuration