{"record":{"id":"3115360ab953c98a","repo":"dotnet/machinelearning","slug":"unable-to-split-the-file-provided-into-multiple-c","errorCode":null,"errorMessage":"Unable to split the file provided into multiple, consistent columns. Readable formats include delimited files such as CSV/TSV. Check for a consistent number of columns and proper escaping and quoting.","messagePattern":"Unable to split the file provided into multiple, consistent columns\\. Readable formats include delimited files such as CSV/TSV\\. Check for a consistent number of columns and proper escaping and quoting\\.","errorType":"exception","errorClass":"InferenceException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/ColumnInference/ColumnInferenceApi.cs","lineNumber":124,"sourceCode":"\n        private static TextFileContents.ColumnSplitResult InferSplit(MLContext context, TextFileSample sample, char? separatorChar, bool? allowQuotedStrings, bool? supportSparse)\n        {\n            var separatorCandidates = separatorChar == null ? TextFileContents.DefaultSeparators : new char[] { separatorChar.Value };\n            var splitInference = TextFileContents.TrySplitColumns(context, sample, separatorCandidates);\n\n            // respect passed-in overrides\n            if (allowQuotedStrings != null)\n            {\n                splitInference.AllowQuote = allowQuotedStrings.Value;\n            }\n            if (supportSparse != null)\n            {\n                splitInference.AllowSparse = supportSparse.Value;\n            }\n\n            if (!splitInference.IsSuccess)\n            {\n                throw new InferenceException(InferenceExceptionType.ColumnSplit,\n                    \"Unable to split the file provided into multiple, consistent columns. \" +\n                    \"Readable formats include delimited files such as CSV/TSV. \" +\n                    \"Check for a consistent number of columns and proper escaping and quoting.\");\n            }\n\n            return splitInference;\n        }\n\n        private static ColumnTypeInference.InferenceResult InferColumnTypes(MLContext context, TextFileSample sample,\n            TextFileContents.ColumnSplitResult splitInference, bool hasHeader, uint? labelColumnIndex, string label)\n        {\n            // infer column types\n            var typeInferenceResult = ColumnTypeInference.InferTextFileColumnTypes(context, sample,\n                new ColumnTypeInference.Arguments\n                {\n                    ColumnCount = splitInference.ColumnCount,\n                    Separator = splitInference.Separator.Value,\n                    AllowSparse = splitInference.AllowSparse,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/ColumnInference/ColumnInferenceApi.cs#L106-L142","documentation":"AutoML's column inference first tries to split each line of the input file into consistent columns. When the split inference fails (InferenceException with InferenceExceptionType.ColumnSplit), the file couldn't be parsed into a fixed number of delimited columns, so AutoML cannot build a DataView from it. This is thrown by InferSplit after the underlying split attempt reports IsSuccess == false.","triggerScenarios":"Calling column inference (InferSplit / the AutoML column-inference API) on a file whose rows have varying delimiter counts, inconsistent quoting/escaping, unsupported separators, sparse-format issues (AllowSparse mismatched), or a file that isn't delimited text at all.","commonSituations":"CSVs with embedded commas/newlines not properly quoted; mixed delimiters (comma in one row, tab in another); files with stray header/comment lines of a different shape; Excel-saved or binary files; JSON or fixed-width data fed where CSV/TSV is expected.","solutions":["Open the file and verify every row has the same number of delimiters; fix or remove malformed rows","Ensure fields containing delimiters, quotes, or newlines are properly quoted and escaped","Confirm the file is plain delimited text (CSV/TSV), not Excel/JSON/binary; re-export if needed","Set the correct separator (e.g. SeparatorCharacters option) and AllowSparse=false for non-sparse data","Clean comment/blank/header lines that break column-count consistency"],"exampleFix":"// before\nvar result = ColumnInferenceApi.InferColumns(\"data.xlsx\", label: \"y\");\n// after\n// export data.xlsx as properly quoted CSV first\nvar result = ColumnInferenceApi.InferColumns(\"data.csv\", label: \"y\");","handlingStrategy":"validation","validationCode":"using var sr = new StreamReader(path);\nvar counts = new HashSet<int>();\nwhile (sr.ReadLine() is string line) counts.Add(line.Split(',').Length);\nif (counts.Count > 1) throw new InvalidDataException($\"Inconsistent column counts: {string.Join(',', counts)}\");","typeGuard":null,"tryCatchPattern":"try { var res = ColumnInferenceApi.InferColumns(path, label); }\ncatch (InferenceException ex) when (ex.Type == InferenceExceptionType.ColumnSplit)\n{ /* fix file format: quoting, delimiters, consistent columns */ }","preventionTips":["Validate every row has the same delimiter count before inference","Properly quote fields containing commas, quotes, or newlines","Only feed plain CSV/TSV text files, not Excel or JSON"],"tags":["dotnet","ml-automl","csv","data-format"],"backgroundTag":"schema-validation-failed","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}