Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datajuicer Data juicer TsvFormatter

From Leeroopedia
Knowledge Sources
Domains Data_Loading, Formatting
Last Updated 2026-02-14 16:00 GMT

Overview

Concrete tool for loading and formatting TSV (tab-separated values) files as datasets provided by Data-Juicer.

Description

TsvFormatter extends LocalFormatter with SUFFIXES = ['.tsv'] and type='csv' with delimiter='\t', reusing the CSV reader with a tab delimiter. It is registered with the FORMATTERS registry via @FORMATTERS.register_module(). This enables Data-Juicer to load TSV-formatted datasets, handling the tab-delimited variant of CSV without requiring users to manually specify the delimiter.

Usage

Use when loading TSV-formatted datasets into Data-Juicer for processing, either through direct instantiation or through the automatic format detection system.

Code Reference

Source Location

Signature

@FORMATTERS.register_module()
class TsvFormatter(LocalFormatter):
    SUFFIXES = [".tsv"]

    def __init__(self, dataset_path, suffixes=None, **kwargs):

Import

from data_juicer.format.tsv_formatter import TsvFormatter

I/O Contract

Inputs

Name Type Required Description
dataset_path str Yes Path to a TSV dataset file or directory containing TSV files
suffixes list No File suffixes to be processed. Default: ['.tsv']
**kwargs Any No Extra arguments passed to the parent LocalFormatter (note: delimiter='\t' is set automatically)

Outputs

Name Type Description
dataset Dataset A unified HuggingFace Dataset loaded from the TSV files

Usage Examples

from data_juicer.format.tsv_formatter import TsvFormatter

# Load a TSV dataset
formatter = TsvFormatter(dataset_path="/path/to/data.tsv")
dataset = formatter.load_dataset(num_proc=4)

# Load from a directory of TSV files
formatter = TsvFormatter(dataset_path="/path/to/tsv_dir/")
dataset = formatter.load_dataset()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment