I have to create a dictionary by reading a file
The information is split into lines
The keys are between brackets but not all of them are keys. Just the ones after [date]
between two keys are the values split into lines, but not all the lines are selectable values
The final result should be something like
d=[key:[units,height,site]]
Some of the keys do not have all the values. Then if either units,height or site are not present, the value should be fulfilled with '' or 0
#info in the file
[System]
serial=130204
[Summary]
file_created=2014-11-20 03:02:09
user=j
....#more info
[date]#after this key starts the keys
...
[AX1]
units=m/s
serial_setting=38400
height=70.4
stats=avg
formula=yes
site=site1
[H4]
serial_setting=38100
height=20.6
stats=std
formula=yes
site=site2
[V3]
units=m
...
Final result in the example
param={AX1:['m/s',70.4,'site1'],H4:['',20.6,'site2'], V3:['m',0,'']}
I know how to create a dictionary from list of lists but not to set default values ('' for the strings values an 0 for the numeric ones) in case some values are missing
I tried with defaultdict from Collections but i am not yet so familiar with this class and probably i am not using all its possibilities
Thanks for any help