Convert CSV to INI
Max file size 100mb.
CSV vs INI Format Comparison
| Aspect | CSV (Source Format) | INI (Target Format) |
|---|---|---|
| Format Overview |
CSV
Comma-Separated Values
Plain text format for storing tabular data where each line represents a row and values are separated by commas (or other delimiters). Universally supported by spreadsheets, databases, and data processing tools. Simple, compact, and human-readable. Tabular Data Universal |
INI
Initialization File
Simple text-based configuration format organized into sections with key-value pairs. Originally used by MS-DOS and Windows for application settings, INI files remain popular for configuration due to their simplicity and readability. Each section is identified by a name in square brackets, with key=value pairs underneath. Configuration Key-Value |
| Technical Specifications |
Structure: Rows and columns in plain text
Delimiter: Comma, semicolon, tab, or pipe Encoding: UTF-8, ASCII, or UTF-8 with BOM Headers: Optional first row as column names Extensions: .csv |
Structure: [Section] headers with key=value pairs
Comments: Lines starting with ; or # Values: Strings, numbers (no native types) Encoding: UTF-8 or ASCII Extensions: .ini, .cfg, .conf |
| Syntax Examples |
CSV uses delimiter-separated values: Name,Age,City Alice,30,New York Bob,25,London Charlie,35,Tokyo |
INI uses sections and key=value pairs: [Alice] Name = Alice Age = 30 City = New York [Bob] Name = Bob Age = 25 City = London [Charlie] Name = Charlie Age = 35 City = Tokyo |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 1972 (early implementations)
RFC Standard: RFC 4180 (2005) Status: Widely used, stable MIME Type: text/csv |
Introduced: 1980s (MS-DOS era)
Standardization: No formal standard (de facto) Status: Stable, widely used MIME Type: text/plain |
| Software Support |
Microsoft Excel: Full support
Google Sheets: Full support LibreOffice Calc: Full support Other: Python, R, pandas, SQL, all databases |
Python: configparser (built-in module)
Windows: Native API (GetPrivateProfileString) PHP: parse_ini_file() built-in function Other: Node.js (ini package), Java, C#, all text editors |
Why Convert CSV to INI?
Converting CSV data to INI format transforms tabular records into structured configuration files with named sections and key-value pairs. This is valuable when you need to generate application configurations from spreadsheet data, create per-entity settings files, or bridge the gap between data management tools and software configuration systems.
Each row of your CSV becomes a named section in the INI file, with the column headers serving as keys and cell values as their corresponding values. Our converter automatically detects the CSV delimiter (comma, semicolon, tab, or pipe), identifies header rows, and uses one column (typically the first) as the section name while mapping remaining columns to key-value pairs within each section.
This conversion is particularly useful for DevOps and system administrators who manage configurations for multiple servers, services, or applications using spreadsheets. Instead of manually creating INI files for each entity, you can maintain all configuration data in a single CSV spreadsheet and batch-convert it to INI format whenever settings change.
The INI format is one of the simplest and most widely supported configuration formats available. It is natively supported by Python's configparser module, PHP's parse_ini_file function, Windows system APIs, and countless other tools and frameworks. This makes CSV to INI conversion an efficient way to deploy configuration data across diverse technology stacks.
Key Benefits of Converting CSV to INI:
- Config Generation: Generate configuration files from spreadsheet data automatically
- Named Sections: Each CSV row becomes a named INI section with key-value pairs
- Auto-Detection: Automatically detects CSV delimiter (comma, semicolon, tab, pipe)
- Header Mapping: CSV column headers become INI keys in each section
- Human-Readable: INI output is easy to read, edit, and verify
- Wide Compatibility: INI is supported by Python, PHP, Windows, .NET, and more
- Data Integrity: All values are preserved exactly as in the original CSV
Practical Examples
Example 1: Server Configuration
Input CSV file (servers.csv):
Server,Host,Port,Protocol,MaxConnections WebServer,192.168.1.10,8080,https,500 Database,192.168.1.20,5432,tcp,100 CacheServer,192.168.1.30,6379,tcp,200 MailServer,192.168.1.40,587,smtp,50
Output INI file (servers.ini):
[WebServer] Host = 192.168.1.10 Port = 8080 Protocol = https MaxConnections = 500 [Database] Host = 192.168.1.20 Port = 5432 Protocol = tcp MaxConnections = 100 [CacheServer] Host = 192.168.1.30 Port = 6379 Protocol = tcp MaxConnections = 200 [MailServer] Host = 192.168.1.40 Port = 587 Protocol = smtp MaxConnections = 50
Example 2: Application User Preferences
Input CSV file (user_prefs.csv):
Username,Theme,Language,FontSize,Notifications alice,dark,en,14,true bob,light,fr,12,false charlie,dark,de,16,true
Output INI file (user_prefs.ini):
[alice] Theme = dark Language = en FontSize = 14 Notifications = true [bob] Theme = light Language = fr FontSize = 12 Notifications = false [charlie] Theme = dark Language = de FontSize = 16 Notifications = true
Example 3: Database Connection Profiles
Input CSV file (db_connections.csv):
Profile,Driver,Host,Database,User,Timeout Production,postgresql,db.prod.com,app_db,app_user,30 Staging,postgresql,db.staging.com,app_db,staging_user,60 Development,sqlite,localhost,dev.db,dev_user,0
Output INI file (db_connections.ini):
[Production] Driver = postgresql Host = db.prod.com Database = app_db User = app_user Timeout = 30 [Staging] Driver = postgresql Host = db.staging.com Database = app_db User = staging_user Timeout = 60 [Development] Driver = sqlite Host = localhost Database = dev.db User = dev_user Timeout = 0
Frequently Asked Questions (FAQ)
Q: What is INI format?
A: INI (Initialization) is a simple text-based configuration file format organized into sections and key-value pairs. Each section starts with a name in square brackets (e.g., [SectionName]), followed by lines of key = value pairs. Comments start with semicolons (;) or hash characters (#). The format originated in the MS-DOS era and is still widely used for application configuration in Python (configparser), PHP (php.ini), Windows, Git (.gitconfig), and many other tools.
Q: How does the CSV delimiter detection work?
A: Our converter uses Python's csv.Sniffer to automatically detect the delimiter used in your CSV file. It supports commas, semicolons, tabs, and pipe characters. The sniffer analyzes a sample of your file to determine the correct delimiter and quoting style. This means your CSV files from Excel, Google Sheets, European locale software (which often uses semicolons), or database exports will all be handled correctly without any manual configuration.
Q: How are CSV rows mapped to INI sections?
A: Each row of the CSV becomes a separate section in the INI file. The first column is typically used as the section name (in square brackets), and the remaining columns become key-value pairs within that section. The column headers from the CSV become the INI keys. If the first column values are not unique, the converter appends a number to make each section name unique.
Q: Will my CSV headers be used as INI keys?
A: Yes! When a header row is detected, the column names become the keys in each INI section. For example, if your CSV has columns "Host", "Port", and "Protocol", the INI output will have key=value pairs like Host = 192.168.1.10, Port = 8080, and Protocol = https. If no header row is detected, generic keys (Key1, Key2, etc.) are generated.
Q: Can I use the INI output with Python's configparser?
A: Yes! The generated INI file is fully compatible with Python's built-in configparser module. You can read it directly with configparser.read('file.ini') and access values using config['SectionName']['KeyName']. The output uses the standard INI syntax that configparser expects, including proper section headers and key = value formatting.
Q: What happens with special characters in CSV data?
A: Values containing special INI characters (like equal signs or semicolons) are properly handled during conversion. The converter ensures that values are written in a way that INI parsers will read correctly. Section names are sanitized to remove characters that are invalid in INI section headers (like square brackets). UTF-8 characters are preserved in the output.
Q: Is there a limit on the number of CSV rows?
A: There is no hard limit, but INI files are designed for configuration rather than large datasets. Each CSV row becomes a section, so a 1000-row CSV produces a 1000-section INI file, which may not be practical for all use cases. INI works best for dozens to hundreds of entities. For very large datasets, consider JSON or YAML as more suitable target formats.
Q: Does the converter support multiline values?
A: Standard INI format does not natively support multiline values. If your CSV cells contain line breaks, the converter will replace them with a space or a continuation character depending on the INI parser compatibility. For multiline configuration data, consider converting to YAML or TOML instead, which have native multiline support.
Q: Does the converter support CSV files from Excel?
A: Yes! CSV files exported from Microsoft Excel, Google Sheets, LibreOffice Calc, and other spreadsheet applications are fully supported. The converter handles both UTF-8 and UTF-8 with BOM encodings, as well as different line ending styles (Windows CRLF, Unix LF, Mac CR). Excel's default comma-separated format and locale-specific semicolon-separated formats are both detected automatically.