{"record":{"id":"404ae0ca1dfc892f","repo":"dotnet/machinelearning","slug":"unable-to-infer-column-types-of-the-file-provided","errorCode":null,"errorMessage":"Unable to infer column types of the file provided.","messagePattern":"Unable to infer column types of the file provided\\.","errorType":"exception","errorClass":"InferenceException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/ColumnInference/ColumnInferenceApi.cs","lineNumber":152,"sourceCode":"            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,\n                    AllowQuote = splitInference.AllowQuote,\n                    ReadMultilines = splitInference.ReadMultilines,\n                    HasHeader = hasHeader,\n                    LabelColumnIndex = labelColumnIndex,\n                    Label = label\n                });\n\n            if (!typeInferenceResult.IsSuccess)\n            {\n                throw new InferenceException(InferenceExceptionType.ColumnDataType, \"Unable to infer column types of the file provided.\");\n            }\n\n            return typeInferenceResult;\n        }\n    }\n}\n","sourceCodeStart":134,"sourceCodeEnd":159,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/ColumnInference/ColumnInferenceApi.cs#L134-L159","documentation":"After splitting the file into columns, AutoML attempts to infer a ML.NET data type for each column. When the type inference result reports IsSuccess == false, InferColumnTypes throws this InferenceException (InferenceExceptionType.ColumnDataType), meaning it couldn't determine usable column types for the file. Usually a follow-on symptom of unparseable or empty data rather than a code bug.","triggerScenarios":"Calling the AutoML column inference API on a file whose column values cannot be parsed into any supported type (all values null/garbage), a file with zero usable data rows, or a file that passed split but has empty/inconsistent fields.","commonSituations":"Empty or nearly empty CSVs (header only); columns full of malformed values (corrupted encodings, mixed binary/text); wrong delimiter causing each row to be a single untyped column; non-UTF8 encodings producing garbage tokens.","solutions":["Verify the file has data rows beyond the header and values are readable text in a supported encoding (UTF-8)","Inspect a few rows manually to confirm values match the expected delimiter and format","Fix column contents that are entirely unparseable (e.g. all nulls, mixed binary)","Run InferSplit first to confirm the file splits cleanly before type inference","Sample-load the file with ML.NET's TextLoader manually to see per-column parse failures"],"exampleFix":"// before\nvar inference = ColumnInferenceApi.InferColumns(\"empty.csv\", label: \"y\");\n// after\n// ensure the file contains rows with valid values, then:\nvar inference = ColumnInferenceApi.InferColumns(\"data-with-rows.csv\", label: \"y\");","handlingStrategy":"validation","validationCode":"var lineCount = File.ReadLines(path).Count();\nif (lineCount <= 1) throw new InvalidDataException(\"File has no data rows\");","typeGuard":null,"tryCatchPattern":"try { var res = ColumnInferenceApi.InferColumns(path, label); }\ncatch (InferenceException ex) when (ex.Type == InferenceExceptionType.ColumnDataType)\n{ /* check file content and encoding */ }","preventionTips":["Ensure data rows exist beyond the header","Use UTF-8 encoding without corruption","Confirm column values are parseable text before inference"],"tags":["dotnet","ml-automl","type-inference","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"}