{"record":{"id":"97e542a2ee4d9511","repo":"deepset-ai/haystack","slug":"csvtodocument-delimiter-must-be-a-single-characte","errorCode":null,"errorMessage":"CSVToDocument: delimiter must be a single character.","messagePattern":"CSVToDocument: delimiter must be a single character\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/components/converters/csv.py","lineNumber":80,"sourceCode":"            If True, the full path of the file is stored in the metadata of the document.\n            If False, only the file name is stored.\n        :param conversion_mode:\n            - \"file\" (default): one Document per CSV file whose content is the raw CSV text.\n            - \"row\": convert each CSV row to its own Document (requires `content_column` in `run()`).\n        :param delimiter:\n            CSV delimiter used when parsing in row mode (passed to ``csv.DictReader``).\n        :param quotechar:\n            CSV quote character used when parsing in row mode (passed to ``csv.DictReader``).\n        \"\"\"\n        self.encoding = encoding\n        self.store_full_path = store_full_path\n        self.conversion_mode = conversion_mode\n        self.delimiter = delimiter\n        self.quotechar = quotechar\n\n        # Basic validation\n        if len(self.delimiter) != 1:\n            raise ValueError(\"CSVToDocument: delimiter must be a single character.\")\n        if len(self.quotechar) != 1:\n            raise ValueError(\"CSVToDocument: quotechar must be a single character.\")\n\n    @component.output_types(documents=list[Document])\n    def run(\n        self,\n        sources: list[str | Path | ByteStream],\n        *,\n        content_column: str | None = None,\n        meta: dict[str, Any] | list[dict[str, Any]] | None = None,\n    ) -> dict[str, Any]:\n        \"\"\"\n        Converts CSV files to a Document (file mode) or to one Document per row (row mode).\n\n        :param sources:\n            List of file paths or ByteStream objects.\n        :param content_column:\n            **Required when** ``conversion_mode=\"row\"``.","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/converters/csv.py#L62-L98","documentation":"CSVToDocument.__init__ validates that the delimiter is exactly one character, since Python's csv module requires single-character delimiters. Passing a multi-character string fails fast at construction.","triggerScenarios":"CSVToDocument(delimiter='; ') or CSVToDocument(delimiter='\\t ' where the source used a multi-char separator like '||' or a tab with trailing spaces).","commonSituations":"Copy-pasting separators from files that use multi-character delimiters; confusing tab ('\\t') with the literal string 'tab'; configurable delimiter sourced from YAML/CLI containing whitespace.","solutions":["Pass a single character, e.g. delimiter=';', ',', or '\\t'.","Pre-process multi-character-delimited files into a single-char-delimited CSV before conversion.","Strip whitespace from user/config-supplied delimiter values before constructing the converter."],"exampleFix":"// before\nCSVToDocument(delimiter='||')\n// after\nimport csv  # or preprocess the file\nconverter = CSVToDocument(delimiter=';')","handlingStrategy":"validation","validationCode":"assert len(delimiter) == 1, f\"delimiter must be a single character, got {delimiter!r}\"\nCSVToDocument(delimiter=delimiter)","typeGuard":"def is_single_char(s: str) -> bool:\n    return isinstance(s, str) and len(s) == 1","tryCatchPattern":"try:\n    converter = CSVToDocument(delimiter=delimiter)\nexcept ValueError as e:\n    if 'single character' in str(e):\n        converter = CSVToDocument(delimiter=delimiter.strip()[0])\n    else:\n        raise","preventionTips":["Strip whitespace from config/CLI-provided delimiters.","Use explicit escapes like '\\t' for tabs, not the word 'tab'.","For multi-char separators, preprocess the file with a custom parser first."],"tags":["validation","csv-converter","constructor-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}