Closed ghost closed 3 years ago
I've found a workaround which seems to be okay, passing a couple of regex substitutions with the null_policy
keyword:
LAS_CLEANERS = [
# matches two words within double quotes
(r'"([a-zA-Z]*) ([a-zA-Z]*)"', r'\1_\2'),
# matches three words within double quotes
(r'"([a-zA-Z]*) ([a-zA-Z]*) ([a-zA-Z]*)"', r'\1_\2_\3')
]
las = lasio.read('data/test_file.las', null_policy=LAS_CLEANERS)
I'm not sure how to generalise this to further number of words. But this works for now :)
Thanks for the report! That's a neat work-around.
Unfortunately lasio is still only written to support numerical data sections (i.e. LAS v2), so I wouldn't expect that to work yet. I'd like to support text data sections but haven't had time to work on it.
OK, fair enough. I'll close the issue for now then, as we have a simple workaround.
No worries - it's certainly something I'd like to have implemented. Thanks for the example!
Hi @kinverarity1 ,
I've realised my solution above has a major disadvantage - it turns off the default NULL_POLICY, so regular null values are ignored!
Is there a way to use some custom regex substitutions, in combination with a NULL_POLICY from lasio.defaults?
At the moment, if one or more of the columns are non-numeric, the NULL_POLICY fails to replace missing values with np.nan
.
This is because when the below array is created https://github.com/kinverarity1/lasio/blob/817fb82914cbe62009f651340ebec51fbb466174/lasio/reader.py#L456-L458
the array will be of type string (<U32), and the missing numbers in lasio.defaults.NULL_SUBS
won't be matched, since we are comparing as string e.g. "-999"
against a number like -999
.
Thanks @Anjum48 - I have opened a new issue for that.
@Connossor I have changed the data section code to split into items while respecting quoted strings. Hopefully that fixes the original issue you raised, although obviously other NULL values are still being ignored per @Anjum48's comment. I've opened #422 to deal with that.
I am encountering an error trying to load a LAS file that has a paramaeter that sometimes contains spaces. This seem to occur for many LAS files that contain picks: the pick name is a text field which may contain spaces.
It is possible to replace these spaces with underscores, or something like that?
Here's an example LAS file:
Here is what I get from LASIO
The result is badly parsed:
PS thanks for your work on the library so far, it is proving tremendously useful!