Closed abfleishman closed 2 years ago
In the short term, you can turn "strict mode" off by passing strict=False
to the GuanoFile constructor:
gf = GuanoFile(path, strict=False)
This will allow guano-py to continue parsing the remainder of the metadata, past the missing Loc Elevation
value:
EPTFUS_20210617_213005.wav
GUANO|Version: 1.0
Firmware Version: App 2.8
Length: 6.30
Loc Position: None
Loc Elevation:
Make: Wildlife Acoustics
Model: Echo Meter Touch 2 Pro
Original Filename: 20210617_213005.wav
Samplerate: 256000
Serial: E2A01358
Species Auto ID: EPTFUS
Species Manual ID:
Timestamp: 2021-06-17T21:30:05-04:00
Note:
WA|Echo Meter|Auto ID: EPTFUS
WA|Song Meter|Prefix: Big brown bat’s iPad
WA|Song Meter|Audio settings: [{"prefix":"Big brown bat’s iPad","trig max len":"0.00","rate":"256000","trig window":"0.00","trig min freq":"0.00","trig level":"0.00","trig max freq":"0.00","gain":"0.00"}]
I should be able to do a guano-py release in a few days to make it more resilient to missing values like this. The specification unfortunately isn't explicit about this case; an optional field which includes a key but no value should be treated as if that key is not present.
Thank you! Will turning strict mode off have any unintended consequences when reading metadata from large batches of files that may have other issues hiding?
Will turning strict mode off have any unintended consequences
Because guano-py was written to serve as the "reference implementation" of the GUANO metadata format, its default behavior is to follow the letter of the specification. This enables using it to write GUANO validators and editors. In the real world, parts of the specification may be interpreted variously, and/or vendors' software may deviate from the letter of the specification while still following the spirit of the specification.
Turning off strict mode basically enables "real world mode", such that it'll make a best effort to parse whatever expected, previously encountered, or unexpected metadata; and will skip any fields that it isn't able to parse successfully. If you've got Python's logging module enabled in your application, it should log at WARN level every time it can't handle a field.
If you disable strict mode and it still chokes on a file, or it fails to parse a field that you believe to be valid-ish, please send it this way and I'll work to make it more resilient.
See also classmethod GuanoFile.register()
which lets you register custom parsing/serialization support for new/unknown/custom namespaced GUANO fields.
guano-py 1.0.14 has been released!
It ignores metadata fields which have no associated value, including in the default "strict mode".
Thanks for your report!
I have some WAV files from an EchoMeter TouchPro that fail to load as a
GuanoFile
(see: EPTFUS_20210617_213005.zip ). Any help would be appreciated.