Classes defined in module datareader
Functions defined in module datareader
Match a floating point number at the beginning of a string
If the beginning of the string matches a floating point number, a list is returned with the float and the remainder of the string; if not, None is returned. Example: splitFloat('123e4rt345e6') returns [1230000.0, 'rt345e6']
Read data from a line matching the ‘type’ specification.
This is a powerful function for reading, interpreting and converting numerical data from a string. Fields in the string s are separated by commas. The ‘type’ argument is a list where each element specifies how the corresponding field should be interpreted. Available values are ‘int’, ‘float’ or some unit (‘kg’, ‘m’, etc.). If the type field is ‘int’ or ‘float’, the data field is converted to the matching type. If the type field is a unit, the data field should be a number and a unit separated by space or not, or just a number. If it is just a number, its value is returned unchanged (as float). If the data contains a unit, the number is converted to the requested unit. It is an error if the datafield holds a non-conformable unit. The function returns a list of ints and/or floats (without the units). If the number of data fields is not equal to the number of type specifiers, the returned list will correspond to the shortest of both and the surplus data or types are ignored, UNLESS the strict flag has been set, in which case a RuntimError is raised. Example:
readData('12, 13, 14.5e3, 12 inch, 1hr, 31kg ', ['int','float','kg','cm','s'])
returns [12, 13.0, 14500.0, 30.48, 3600.0]
..warning
You need to have the GNU ``units`` command installed for the unit
conversion to work.