R
Roberto A. F. De Almeida
Hi,
I'm interested in parsing a file containing this "structure":
"""dataset {
int catalog_number;
sequence {
string experimenter;
int32 time;
structure {
float64 latitude;
float64 longitude;
} location;
sequence {
float depth;
float temperature;
} xbt;
} casts;
} data;"""
I want to obtain a dictionary like this:
{'casts': {'experimenter': None,
'location': {'latitude': None, 'longitude': None},
'time': None,
'xbt': {'depth': None, 'temperature': None}},
'catalog_number': None}
The values ('None') will be filled later. I tried to do the parsing
using regular expressions, but things became too complicated. I had
more success using SimpleParse, but I'm interested in more insights on
different ways of parsing this file.
TIA,
Roberto
I'm interested in parsing a file containing this "structure":
"""dataset {
int catalog_number;
sequence {
string experimenter;
int32 time;
structure {
float64 latitude;
float64 longitude;
} location;
sequence {
float depth;
float temperature;
} xbt;
} casts;
} data;"""
I want to obtain a dictionary like this:
{'casts': {'experimenter': None,
'location': {'latitude': None, 'longitude': None},
'time': None,
'xbt': {'depth': None, 'temperature': None}},
'catalog_number': None}
The values ('None') will be filled later. I tried to do the parsing
using regular expressions, but things became too complicated. I had
more success using SimpleParse, but I'm interested in more insights on
different ways of parsing this file.
TIA,
Roberto