pentaho/pentaho-kettle · warning · KettleException

TextFileInput.Log.Error.ErrorConvertingLine

TextFileInput.Log.Error.ErrorConvertingLine

Error message

TextFileInput.Log.Error.ErrorConvertingLine

What it means

TextFileInputUtils.guessStringsFromLine() parses a single sample line into string fields using the configured delimiter/enclosure settings. Any exception during that parsing is wrapped in a KettleException with message TextFileInput.Log.Error.ErrorConvertingLine plus e.toString(). It is thrown from metadata auto-guessing, so it indicates the sample line cannot be split with the current settings.

Solutions

  1. Check the cause (e.toString() in the message) to see the actual parse failure.
  2. Verify the delimiter and enclosure settings match the sample file (e.g. tab vs ';').
  3. Fix the sample line or pick a clean, representative line for guessing.
  4. Ensure enclosed fields are properly quoted and escaped per RFC 4180.
  5. Re-run field guessing after correcting the content type settings.

Example fix

// before: unbalanced enclosure confuses the guesser
String line = "a;\"b;c;d"; // missing closing quote
// after
String line = "a;\"b;c\";d";
Defensive patterns

Strategy: validation

Validate before calling

if (line == null || line.isEmpty())
  throw new KettleException("Sample line is empty; cannot guess fields");
long enclosures = line.chars().filter(c -> c == '"').count();
if (enclosures % 2 != 0) throw new KettleException("Unbalanced enclosure characters in sample line");

Type guard

if (line == null || line.indexOf(delimiter) < 0) return false; // line not splittable with this delimiter

Try / catch

try {
  String[] fields = TextFileInputUtils.guessStringsFromLine(log, line, delimiter, enclosure, escape);
} catch (KettleException e) {
  log.logBasic("Guess failed (" + e.getMessage() + "); using single-field layout");
  fields = new String[] { line };
}

Prevention

When it happens

Trigger: Calling guessStringsFromLine (e.g. from the dialog's 'guess fields' or meta.guessStringsFromLine during getFields auto-configuration) with a line whose enclosure/escape/delimiter structure causes the parser to throw (e.g. unbalanced quotes, null data stream).

Common situations: Sample line contains an odd number of enclosure characters ("); wrong delimiter guessed for the actual file; enclosed fields containing delimiters/newlines confusing the splitter; passing a null line into the guesser.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/91989cc52df0fdde. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java:271

        // Fixed file format: Simply get the strings at the required positions...
        for ( int i = 0; i < inf.inputFields.length; i++ ) {
          BaseFileField field = inf.inputFields[i];

          int length = line.length();

          if ( field.getPosition() + field.getLength() <= length ) {
            strings.add( line.substring( field.getPosition(), field.getPosition() + field.getLength() ) );
          } else {
            if ( field.getPosition() < length ) {
              strings.add( line.substring( field.getPosition() ) );
            } else {
              strings.add( "" );
            }
          }
        }
      }
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( PKG, "TextFileInput.Log.Error.ErrorConvertingLine", e
          .toString() ), e );
    }

    return strings.toArray( new String[strings.size()] );
  }

  public static final String getLine( LogChannelInterface log, BufferedInputStreamReader reader, int formatNr,
                                      StringBuilder line ) throws KettleFileException {
    EncodingType type = EncodingType.guessEncodingType( reader.getEncoding() );
    return getLine( log, reader, type, formatNr, line );
  }

  public static final String getLine( LogChannelInterface log, BufferedInputStreamReader reader, EncodingType encodingType,
                                      int fileFormatType, StringBuilder line, String regex )
    throws KettleFileException {

    return getLine( log, reader, encodingType, fileFormatType, line, regex, 0 ).line;

View on GitHub (pinned to f3058517a1)