parse_spaced_rows#

parse_spaced_rows(data_str)#

Parse space-separated integers into one row or multiple rows.

Accepts commas or semicolons as row separators.

Examples

  • "1 2 3"[1, 2, 3]

  • "1 2 3, 4 5 -6"[[1, 2, 3], [4, 5, -6]]

  • "1 2 3 ; 4 5 -6"[[1, 2, 3], [4, 5, -6]]

Parameters:

data_str (str) – Input string.

Returns:

A single list of ints if one row is given, otherwise list of rows.

Return type:

List[int] | List[List[int]]