{"record":{"id":"3255726936dadb15","repo":"deepset-ai/haystack","slug":"csvtodocument-row-content-column-content-colum","errorCode":null,"errorMessage":"CSVToDocument(row): content_column='{content_column}' not found in header for {source}. Available columns: {header}","messagePattern":"CSVToDocument\\(row\\): content_column='(.+?)' not found in header for (.+?)\\. Available columns: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/components/converters/csv.py","lineNumber":178,"sourceCode":"                    )\n            except Exception:\n                pass\n\n            # Create DictReader; if this fails, raise (no fallback)\n            try:\n                # ``restkey`` ensures surplus fields on ragged rows (rows with more values than the\n                # header, e.g. an unquoted comma inside a value) land under an explicit string key\n                # instead of the default ``None`` key, which would break ``Document`` id generation.\n                reader = csv.DictReader(\n                    io.StringIO(data), delimiter=self.delimiter, quotechar=self.quotechar, restkey=\"extra_columns\"\n                )\n            except Exception as e:\n                raise RuntimeError(f\"CSVToDocument(row): could not parse CSV rows for {source}: {e}\") from e\n\n            # Validate header contains content_column; strict error if missing\n            header = reader.fieldnames or []\n            if content_column not in header:\n                raise ValueError(\n                    f\"CSVToDocument(row): content_column='{content_column}' not found in header \"\n                    f\"for {source}. Available columns: {header}\"\n                )\n\n            # Build documents; if a row processing fails, raise immediately (no skip)\n            for i, row in enumerate(reader):\n                try:\n                    doc = self._build_document_from_row(\n                        row=row, base_meta=merged_metadata, row_index=i, content_column=content_column\n                    )\n                except Exception as e:\n                    raise RuntimeError(f\"CSVToDocument(row): failed to process row {i} for {source}: {e}\") from e\n                documents.append(doc)\n\n        return {\"documents\": documents}\n\n    # ----- helpers -----\n    def _safe_value(self, value: Any) -> str:","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/converters/csv.py#L160-L196","documentation":"In row mode the component is strict: the content_column supplied to run() must appear in the CSV header, otherwise it cannot know which field holds the document text. The error lists the actual header columns found.","triggerScenarios":"run(sources=[...], content_column='body') on a CSV whose header row lacks 'body' — due to typo, case mismatch, wrong delimiter mangling the header, or a missing header row.","commonSituations":"Renamed columns upstream; case-sensitive mismatch ('Text' vs 'text'); delimiter mismatch causing the whole first line to be one field; CSV without a header at all.","solutions":["Set content_column to a name exactly matching a header field (case-sensitive).","Inspect the 'Available columns' list in the message and pick the right one.","Fix delimiter/quotechar so the header parses into the correct fields.","Add or regenerate the header row in the CSV file."],"exampleFix":"// before\ncsv_conv.run(sources=[f], content_column=\"Body\")\n// after (header is: id,text)\ncsv_conv.run(sources=[f], content_column=\"text\")","handlingStrategy":"validation","validationCode":"import csv, io\ndef ensure_content_column(data: bytes, content_column: str, delimiter: str = \",\") -> None:\n    header = next(csv.reader(io.StringIO(data.decode(\"utf-8\")), delimiter=delimiter)) or []\n    if content_column not in header:\n        raise ValueError(f\"content_column {content_column!r} not in header {header}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = conv.run(sources=[f], content_column=col)\nexcept ValueError as e:\n    if \"not found in header\" in str(e):\n        col = col.lower()  # retry with normalized case or pick a column you parse from the header\n        result = conv.run(sources=[f], content_column=col)\n    else:\n        raise","preventionTips":["Match header names exactly (case-sensitive); check for typos.","Fix delimiter so the header parses into correct fields.","Ensure CSV files include a header row.","Normalize column names upstream before ingestion."],"tags":["python","csv","column-not-found","configuration"],"backgroundTag":"column-not-found","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}