eelbrain.load.tsv(path=None, names=True, types=None, delimiter='auto', skiprows=0, start_tag=None, ignore_missing=False, empty=None, random=None, strip=False, encoding=None, comment='^#', percent_to_proportion=False, **fmtparams)

Load a Dataset from a text file.

  • path (str) – Path to the file (if omitted, use a system file dialog). Files ending in *.gz are automatically decompressed.

  • names (Sequence of str | bool) –

    Column/variable names.

    • True (default): look for names on the first line of the file

    • ['name1', ...] use these names

    • False: use “v1”, “v2”, …

  • types (str | dict) –

    Column data types:

    - 'a': determine automatically
    - 'f': Factor
    - 'v': Var
    - 'b': boolean Var

    Specified either as string, with one type per columnc (e.g. 'ffvva') or as {column_name: data_type} dictionary (e.g. {'participant': 'f'}); unspecified columns default to 'a'.

  • delimiter (str) – Value delimiting cells in the input file (default depends on path: ',' if the extension is '.csv', otherwise '\t').

  • skiprows (int) – Skip so many rows at the beginning of the file (for tsv files with headers). Column names are expected to come after the skipped rows. skiprows is applied after start_tag.

  • start_tag (str) – Alternative way to skip header rows. The table is assumed to start on the line following the last line in the file that starts with start_tag.

  • ignore_missing (bool) – Ignore rows with missing values (i.e., lines that contain fewer delimiter than the others; by default this raises an IOError). For rows with missing values, NaN is substituted for numerical and "" for categorial variables.

  • empty (number | 'nan') – For numerical variables, substitute this value for empty entries. For example, if a column in a file contains ['5', '3', ''], this is read by default as Factor(['5', '3', '']). With empty=0, it is read as Var([5, 3, 0]). With empty='nan', it is read as Var([5, 3, nan]).

  • random (str | sequence of str) – Names of the columns that should be assigned as random factor.

  • strip (bool) – Strip white-space from all categorial variables.

  • encoding (str) – Text file encoding (see open()).

  • comment (str) – Regular expression for lines to skip (default is lines starting with #).

  • percent_to_proportion (bool) – Convert columns that end in the percent sign into a float reflecting proportion (i.e. strip the percent sign and divide the number by 100).

  • **fmtparams – Further formatting parameters for csv.reader(). For example, a fixed-width column file can be loaded with skipinitialspace=True (as long as there are no empty cells).

Return type: