2024-05-06 07:44:35 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2024-05-07 08:17:09 +02:00
|
|
|
if len(sys.argv) >= 2:
|
|
|
|
filename = sys.argv[1]
|
|
|
|
else:
|
|
|
|
filename = "data.txt"
|
2024-05-06 07:44:35 +02:00
|
|
|
|
|
|
|
data = {}
|
|
|
|
|
|
|
|
with open(filename, "r") as fileobj:
|
2024-05-07 08:17:09 +02:00
|
|
|
for i, line in enumerate(fileobj):
|
2024-05-06 07:44:35 +02:00
|
|
|
line = line.strip() # remove whitespace from start/end of line
|
|
|
|
|
|
|
|
if line.startswith('#'):
|
|
|
|
# ignore comment lines
|
|
|
|
continue
|
|
|
|
|
|
|
|
name, raw_data = line.split(":", 1) # split line at first colon
|
|
|
|
items = raw_data.split(",") # split raw data at commas
|
|
|
|
|
|
|
|
data[name.strip()] = items
|
|
|
|
|
|
|
|
|
|
|
|
for key in data:
|
|
|
|
print(key, data[key])
|