fromregex(file, regexp, dtype, encoding=None)
The returned array is always a structured array, and is constructed from all matches of the regular expression in the file. Groups in the regular expression are converted to fields of the structured array.
Dtypes for structured arrays can be specified in several forms, but all forms specify at least the data type and field name. For details see :None:None:`basics.rec`
.
Filename or file object to read.
Now accepts :None:None:`os.PathLike`
implementations.
Regular expression used to parse the file. Groups in the regular expression correspond to fields in the dtype.
Dtype for the structured array; must be a structured datatype.
Encoding used to decode the inputfile. Does not apply to input streams.
When dtype
is not a valid dtype for a structured array.
The output array, containing the part of the content of :None:None:`file`
that was matched by :None:None:`regexp`
. output
is always a structured array.
Construct an array from a text file, using regular expression parsing.
>>> from io import StringIO
... text = StringIO("1312 foo\n1534 bar\n444 qux")
>>> regexp = r"(\d+)\s+(...)" # match [digits, whitespace, anything]
... output = np.fromregex(text, regexp,
... [('num', np.int64), ('key', 'S3')])
... output array([(1312, b'foo'), (1534, b'bar'), ( 444, b'qux')], dtype=[('num', '<i8'), ('key', 'S3')])
>>> output['num'] array([1312, 1534, 444])See :
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.loadtxt
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them