The 3 methods for extracting data are:
Let's start by just trying to read the file.
In [1]:
!head -24 ../data/core_analysis_example.spwla
In [5]:
record_fields = {
'header': [['well', 'country', 'date'], ['company']], # Occurs on 2 lines
'features': ['a', 'b', 'c', 'd', 'company', 'feature'],
'range': ['w', 'x', 'start', 'stop', 'y', 'z'],
'depth': ['depth', 'alpha', 'beta'],
'descr': ['description'],
'data': ['data'], # Capture as array
}
In [6]:
record_type = {
10: 'header',
15: 'features',
20: 'range',
30: 'depth',
36: 'descr',
40: 'data',
}
In [172]:
fname = "../data/core_analysis_example.spwla"
with open(fname, 'r') as f:
data = f.read()
def get_blocks(data):
for line in data:
if line[:2].isnumeric():
code = line[:2]
continue
yield code, line
for code, line in get_blocks(data.split('\n')):
rec_type = record_type[int(code)]
fields = record_fields[rec_type]
features = []
if rec_type == 'features':
features.append(None)
OK, this is going to be horrendous. It's doable, but won't be pretty.
It doesn't help that I have no idea what kind of variance to expect in this format.
In [ ]: