{"record":{"id":"1f37e4d8ec71e908","repo":"FlowiseAI/Flowise","slug":"column-column-not-found-in-csv-file","errorCode":null,"errorMessage":"Column ${column} not found in CSV file.","messagePattern":"Column (.+?) not found in CSV file\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Csv/CsvLoader.ts","lineNumber":65,"sourceCode":"            meta: { fields = [] }\n        } = Papa.parse<{ [K: string]: string }>(raw.trim(), {\n            delimiter: separator,\n            header: true\n        })\n\n        if (column !== undefined) {\n            if (!fields.length) {\n                throw new Error(`Unable to resolve fields from header.`)\n            }\n\n            let searchIdx = column\n\n            if (typeof column == 'number') {\n                searchIdx = fields[column]\n            }\n\n            if (!fields.includes(searchIdx as string)) {\n                throw new Error(`Column ${column} not found in CSV file.`)\n            }\n\n            // Note TextLoader will raise an exception if the value is null.\n            return parsed.map((row) => row[searchIdx])\n        }\n\n        return parsed.map((row) => fields.map((key) => `${key.trim() || '_0'}: ${row[key]?.trim()}`).join('\\n'))\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":75,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Csv/CsvLoader.ts#L47-L75","documentation":"CsvLoader resolved header fields successfully but the requested column was not among them. column may be a string name or a numeric index; when numeric it is first mapped to fields[column]. If that mapped name (or the literal string) is not in fields, this throws.","triggerScenarios":"User typed 'email_address' but the header is 'email'; numeric index out of range (e.g., 5 in a 3-column file maps to undefined); trailing whitespace in the header name (e.g., 'email ' vs 'email'); case mismatch.","commonSituations":"Schema drift between the expected and actual CSV header; column name copy-pasted from a spec but the file uses different naming; 1-based vs 0-based indexing confusion when passing a number.","solutions":["Print the resolved fields (Papa meta.fields) and match the column name exactly, including case and whitespace.","If passing a numeric index, remember it is 0-based and must be within fields.length.","Normalize header whitespace upstream: trim each field name before comparison."],"exampleFix":"// before\nif (!fields.includes(searchIdx as string)) {\n  throw new Error(`Column ${column} not found in CSV file.`)\n}\n// after - list available fields to aid debugging\nif (!fields.includes(searchIdx as string)) {\n  throw new Error(`Column ${JSON.stringify(column)} not found. Available: ${JSON.stringify(fields)}`)\n}","handlingStrategy":"validation","validationCode":"import Papa from 'papaparse'\n\nfunction resolveColumn(raw: string, column: string | number, separator?: string): string {\n  const { meta: { fields = [] } } = Papa.parse(raw.trim(), { delimiter: separator, header: true, preview: 1 })\n  const trimmed = fields.map((f) => f.trim())\n  const resolved = typeof column === 'number' ? trimmed[column] : column\n  if (!trimmed.includes(typeof column === 'number' ? resolved : column.trim())) {\n    throw new Error(`Column ${JSON.stringify(column)} not found. Available: ${JSON.stringify(trimmed)}`)\n  }\n  return resolved\n}","typeGuard":"function columnExists(raw: string, column: string | number, separator?: string): boolean {\n  const { meta: { fields = [] } } = Papa.parse(raw.trim(), { delimiter: separator, header: true, preview: 1 })\n  const trimmed = fields.map((f) => f.trim())\n  if (typeof column === 'number') return column >= 0 && column < trimmed.length\n  return trimmed.includes(column.trim())\n}","tryCatchPattern":null,"preventionTips":["Print Papa meta.fields during development to see the exact header names.","Trim header names before comparison to avoid whitespace mismatches.","Use 0-based numeric indices within fields.length."],"tags":["csv","parsing","validation","papaparse"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}