Parse INI File to JSON
Beginner Mode
Start your terminal to use beginner mode.
Scenario
A configuration file in INI format contains settings for multiple components. You need to extract database configuration values for use in another application.
Task
Write a Python script at /home/interview/parse_config.py that reads /home/interview/config.ini, extracts all key-value pairs from the database section, and saves them as a JSON file to /home/interview/config.json.
Note: You can use Python's configparser module to parse INI files.
Example
Expected output format in /home/interview/config.json:
{
"host": "localhost",
"port": "5432",
"name": "appdb",
"user": "admin"
}
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
Cisco