{ } Raw JSON

bundles / scipy 1.17.1 / 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 : str

the attribute string.

Returns

name : str

name of the attribute

value : str

value of the attribute

next : str

next 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")
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   ")

Aliases

  • scipy.io.arff._arffread.tokenize_attribute