Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for .btl bottle files #41

Open
adyork opened this issue May 30, 2017 · 5 comments
Open

Documentation for .btl bottle files #41

adyork opened this issue May 30, 2017 · 5 comments
Assignees

Comments

@adyork
Copy link

adyork commented May 30, 2017

Thank you for adding bottle file support. Could you add documentation for this type of file?

I am getting an error when trying to load the sample bottle file.
Using seabird Version: 0.10.2


from seabird import fCNV
data = fCNV('MI18MHDR.btl')
data.attributes  # Gives the header
data.keys()  # Gives the data headers, i.e. the available variables.
data['time']  # For example, returns to you the time of the measurement.

#If you have pandas installed you can also use:
#data.as_DataFrame()  # To have all the data as a pandas' dataFrame

I get the following:

DEBUG:root:Openning file: MI18MHDR.btl
...
seabird\seabird\cnv.py
line 179, in prepare_data
attrib_text = re.search(r"""\n \s+ Bottle \s+ Date \s+ (.*) \s+\r?\n \s+ Position \s+ Time""", self.parsed['header'], re.VERBOSE).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

@dnowacki-usgs
Copy link

The regex isn't properly matching the bottle header line. I'm no regex whiz, but in testing it does successfully match the first line (string beginning with "Bottle") but fails to match the newline and second header line.

@thiamugb
Copy link

hi all,
an issue for this i have the same error

nv.py", line 179, in prepare_data
attrib_text = re.search(r"""\n \s+ Bottle \s+ Date \s+ (.*) \s+\r?\n \s+ Position \s+ Time""", self.parsed['header'], re.VERBOSE).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

@joefutrelle
Copy link

I have a .btl file in hand that this regex fails on.

The problem is the repeated use of spaces around \s+, which requires that there be at least three spaces at that point in the line being parsed. But in the .btl file I'm looking at there are only two spaces after the newline and before Position, and there are no spaces before the newline. When I use this regex:

\s+Bottle\s+Date\s+(.*)\s*\r?\n\s+Position\s+Time

it works. It is not at all clear to me that the author intended to require at least three spaces at those points in the regex.

@ghost
Copy link

ghost commented Aug 21, 2018

@joefutrelle, is it possible for you to create an example code how you changed the regex? This would be great.
And I would love a documentation for the bottle-files.

@joefutrelle
Copy link

@MaraMuchow as it turns out, regexes are a poor way to parse .btl files, because in .btl files the columns are fixed-width. This is especially an issue in the numeric columns where there may not even be a space between two adjacent cells.

I have some code that parses .btl files successfully but it has some project-specific stuff about extracting metadata from our file naming convention. Otherwise it is pretty general, and you can see it here:

https://github.com/WHOIGit/lter-ctd-processing

@castelao castelao self-assigned this Aug 30, 2018
castelao added a commit that referenced this issue Oct 14, 2018
It does not necessarily has space(s) in the end of the header line
(Bottle Date ...).

Thanks @adyork for reporting this bug.
castelao added a commit that referenced this issue Jan 6, 2019
It does not necessarily has space(s) in the end of the header line
(Bottle Date ...).

Thanks @adyork for reporting this bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants