Skip to content

Function to convert MIxS format (value + units) to numeric (value only) #10

@lukenoaa

Description

@lukenoaa

Here is a Python function that works to convert MIxS format (value [space] units) to numeric (value only):

def mixs_to_numeric(value_plus_units):
    '''Takes a value with units after it (str) and returns only the numeric value (float)'''
    '''Does not support scientific notation (yet)'''
    '''Inputs containing no numerals or dash or period will return np.nan'''
    value_only = re.sub(r'([-\.0-9]*).*', r'\1', value_plus_units)
    if value_only == '':
        return(np.nan)
    else:
        return(float(value_only))

This could be integrated into Opal (issue #5) or a Python script that converts a MIxS-formatted sample data file and returns a fully machine-readable metadata file.

@ksilnoaa @Zenith2198

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions