dotnet/machinelearning · error · InferenceException

Unable to split the file provided into multiple, consistent

Error message

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.

What it means

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.

Source

Thrown at src/Microsoft.ML.AutoML/ColumnInference/ColumnInferenceApi.cs:124

        private static TextFileContents.ColumnSplitResult InferSplit(MLContext context, TextFileSample sample, char? separatorChar, bool? allowQuotedStrings, bool? supportSparse)
        {
            var separatorCandidates = separatorChar == null ? TextFileContents.DefaultSeparators : new char[] { separatorChar.Value };
            var splitInference = TextFileContents.TrySplitColumns(context, sample, separatorCandidates);

            // respect passed-in overrides
            if (allowQuotedStrings != null)
            {
                splitInference.AllowQuote = allowQuotedStrings.Value;
            }
            if (supportSparse != null)
            {
                splitInference.AllowSparse = supportSparse.Value;
            }

            if (!splitInference.IsSuccess)
            {
                throw new InferenceException(InferenceExceptionType.ColumnSplit,
                    "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.");
            }

            return splitInference;
        }

        private static ColumnTypeInference.InferenceResult InferColumnTypes(MLContext context, TextFileSample sample,
            TextFileContents.ColumnSplitResult splitInference, bool hasHeader, uint? labelColumnIndex, string label)
        {
            // infer column types
            var typeInferenceResult = ColumnTypeInference.InferTextFileColumnTypes(context, sample,
                new ColumnTypeInference.Arguments
                {
                    ColumnCount = splitInference.ColumnCount,
                    Separator = splitInference.Separator.Value,
                    AllowSparse = splitInference.AllowSparse,

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Open the file and verify every row has the same number of delimiters; fix or remove malformed rows
  2. Ensure fields containing delimiters, quotes, or newlines are properly quoted and escaped
  3. Confirm the file is plain delimited text (CSV/TSV), not Excel/JSON/binary; re-export if needed
  4. Set the correct separator (e.g. SeparatorCharacters option) and AllowSparse=false for non-sparse data
  5. Clean comment/blank/header lines that break column-count consistency

Example fix

// before
var result = ColumnInferenceApi.InferColumns("data.xlsx", label: "y");
// after
// export data.xlsx as properly quoted CSV first
var result = ColumnInferenceApi.InferColumns("data.csv", label: "y");
Defensive patterns

Strategy: validation

Validate before calling

using var sr = new StreamReader(path);
var counts = new HashSet<int>();
while (sr.ReadLine() is string line) counts.Add(line.Split(',').Length);
if (counts.Count > 1) throw new InvalidDataException($"Inconsistent column counts: {string.Join(',', counts)}");

Try / catch

try { var res = ColumnInferenceApi.InferColumns(path, label); }
catch (InferenceException ex) when (ex.Type == InferenceExceptionType.ColumnSplit)
{ /* fix file format: quoting, delimiters, consistent columns */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/3115360ab953c98a. Report an issue: GitHub.