{"record":{"id":"5c6b518159184ccc","repo":"stanford-oval/storm","slug":"content-column-content-column-not-found-in-the-c","errorCode":null,"errorMessage":"Content column {content_column} not found in the csv file.","messagePattern":"Content column (.+?) not found in the csv file\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/utils.py","lineNumber":245,"sourceCode":"            qdrant = QdrantVectorStoreManager._init_offline_vector_db(\n                vector_store_path=vector_store_path,\n                collection_name=collection_name,\n                model=model,\n            )\n        else:\n            raise ValueError(\n                \"Invalid vector_db_mode. Please provide either 'online' or 'offline'.\"\n            )\n        if qdrant is None:\n            raise ValueError(\"Qdrant client is not initialized.\")\n\n        # read the csv file\n        import pandas as pd\n\n        df = pd.read_csv(file_path)\n        # check that content column exists and url column exists\n        if content_column not in df.columns:\n            raise ValueError(\n                f\"Content column {content_column} not found in the csv file.\"\n            )\n        if url_column not in df.columns:\n            raise ValueError(f\"URL column {url_column} not found in the csv file.\")\n\n        documents = [\n            Document(\n                page_content=row[content_column],\n                metadata={\n                    \"title\": row.get(title_column, \"\"),\n                    \"url\": row[url_column],\n                    \"description\": row.get(desc_column, \"\"),\n                },\n            )\n            for row in df.to_dict(orient=\"records\")\n        ]\n\n        # split the documents","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/utils.py#L227-L263","documentation":"After reading the CSV with pandas, the requested content_column is not among df.columns. The header-based lookups are case- and whitespace-sensitive, so even similar names fail.","triggerScenarios":"Passing content_column='Content' when the header is 'content', a name with trailing whitespace/BOM (common with Excel-exported CSVs), or a column that simply does not exist.","commonSituations":"Vendor CSVs with BOM-prefixed first header (pd.read_csv yields '\\ufeffcontent'), renamed headers, or dialect differences between the exporting and ingesting teams.","solutions":["Inspect df.columns (e.g. print(list(df.columns))) and match the exact string","Load with encoding='utf-8-sig' to strip BOM, or normalize headers: df.columns = df.columns.str.strip()","Regenerate the CSV with the expected header if the column is truly absent"],"exampleFix":"# before\ndf = pd.read_csv('d.csv')\ncreate_or_update_vector_store('c', 'offline', 'd.csv', 'Content', 'url')\n# after\ndf = pd.read_csv('d.csv', encoding='utf-8-sig')\ndf.columns = df.columns.str.strip()\ndf.to_csv('d.csv', index=False)\ncreate_or_update_vector_store('c', 'offline', 'd.csv', 'content', 'url')","handlingStrategy":"validation","validationCode":"import pandas as pd\ndf = pd.read_csv(file_path, nrows=0)\ndf.columns = df.columns.str.strip()\nassert content_column in df.columns, f'{content_column!r} not in {list(df.columns)}'","typeGuard":"def content_column_exists(csv_path: str, col: str) -> bool:\n    import pandas as pd\n    headers = pd.read_csv(csv_path, nrows=0, encoding='utf-8-sig').columns.str.strip()\n    return col in headers","tryCatchPattern":"try:\n    create_or_update_vector_store('c', mode, f, content_column, url_column, ...)\nexcept ValueError as e:\n    if 'not found in the csv file' in str(e):\n        import pandas as pd\n        raise SystemExit(f'Bad column; available: {pd.read_csv(f, nrows=0).columns.tolist()}') from e\n    raise","preventionTips":["Always read CSVs with encoding='utf-8-sig' to kill Excel BOMs","Normalize headers with df.columns.str.strip() before choosing column names","Log available columns whenever ingestion fails on schema"],"tags":["csv","pandas","column-name","validation"],"backgroundTag":"column-not-found","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}