bundles / scipy 1.18.0 / scipy / io / arff / _arffread / tokenize_attribute
function
scipy.io.arff._arffread:tokenize_attribute
source: /scipy/io/arff/_arffread.py:515
Signature
def tokenize_attribute(iterable, attribute)Summary
Parse a raw string in header (e.g., starts by @attribute).
Extended Summary
Given a raw string attribute, try to get the name and type of the attribute. Constraints:
The first line must start with @attribute (case insensitive, and space like characters before @attribute are allowed)
Works also if the attribute is spread on multilines.
Works if empty lines or comments are in between
Parameters
attribute: strthe attribute string.
Returns
name: strname of the attribute
value: strvalue of the attribute
next: strnext line to be parsed
Examples
If attribute is a string defined in python as r"floupi real", will return floupi as name, and real as value.from scipy.io.arff._arffread import tokenize_attribute iterable = iter([0] * 10) # dummy iterator✓
tokenize_attribute(iterable, r"@attribute floupi real")
✗(<scipy.io.arff._arffread.NumericAttribute object at 0x7fa8fe6a7250>, 0)If attribute is r"'floupi 2' real", will return 'floupi 2' as name, and real as value.
tokenize_attribute(iterable, r" @attribute 'floupi 2' real ")
✗(<scipy.io.arff._arffread.NumericAttribute object at 0x7fa8e4ff3360>, 0)
Aliases
scipy.io.arff._arffread.tokenize_attribute