{"record":{"id":"91989cc52df0fdde","repo":"pentaho/pentaho-kettle","slug":"textfileinput-log-error-errorconvertingline","errorCode":"TextFileInput.Log.Error.ErrorConvertingLine","errorMessage":"TextFileInput.Log.Error.ErrorConvertingLine","messagePattern":"TextFileInput\\.Log\\.Error\\.ErrorConvertingLine","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"warning","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java","lineNumber":271,"sourceCode":"        // Fixed file format: Simply get the strings at the required positions...\n        for ( int i = 0; i < inf.inputFields.length; i++ ) {\n          BaseFileField field = inf.inputFields[i];\n\n          int length = line.length();\n\n          if ( field.getPosition() + field.getLength() <= length ) {\n            strings.add( line.substring( field.getPosition(), field.getPosition() + field.getLength() ) );\n          } else {\n            if ( field.getPosition() < length ) {\n              strings.add( line.substring( field.getPosition() ) );\n            } else {\n              strings.add( \"\" );\n            }\n          }\n        }\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"TextFileInput.Log.Error.ErrorConvertingLine\", e\n          .toString() ), e );\n    }\n\n    return strings.toArray( new String[strings.size()] );\n  }\n\n  public static final String getLine( LogChannelInterface log, BufferedInputStreamReader reader, int formatNr,\n                                      StringBuilder line ) throws KettleFileException {\n    EncodingType type = EncodingType.guessEncodingType( reader.getEncoding() );\n    return getLine( log, reader, type, formatNr, line );\n  }\n\n  public static final String getLine( LogChannelInterface log, BufferedInputStreamReader reader, EncodingType encodingType,\n                                      int fileFormatType, StringBuilder line, String regex )\n    throws KettleFileException {\n\n    return getLine( log, reader, encodingType, fileFormatType, line, regex, 0 ).line;\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/fileinput/text/TextFileInputUtils.java#L253-L289","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check the cause (e.toString() in the message) to see the actual parse failure.","Verify the delimiter and enclosure settings match the sample file (e.g. tab vs ';').","Fix the sample line or pick a clean, representative line for guessing.","Ensure enclosed fields are properly quoted and escaped per RFC 4180.","Re-run field guessing after correcting the content type settings."],"exampleFix":"// before: unbalanced enclosure confuses the guesser\nString line = \"a;\\\"b;c;d\"; // missing closing quote\n// after\nString line = \"a;\\\"b;c\\\";d\";","handlingStrategy":"validation","validationCode":"if (line == null || line.isEmpty())\n  throw new KettleException(\"Sample line is empty; cannot guess fields\");\nlong enclosures = line.chars().filter(c -> c == '\"').count();\nif (enclosures % 2 != 0) throw new KettleException(\"Unbalanced enclosure characters in sample line\");","typeGuard":"if (line == null || line.indexOf(delimiter) < 0) return false; // line not splittable with this delimiter","tryCatchPattern":"try {\n  String[] fields = TextFileInputUtils.guessStringsFromLine(log, line, delimiter, enclosure, escape);\n} catch (KettleException e) {\n  log.logBasic(\"Guess failed (\" + e.getMessage() + \"); using single-field layout\");\n  fields = new String[] { line };\n}","preventionTips":["Pick clean, representative sample lines for field guessing.","Confirm delimiter/enclosure settings against the raw file in a text editor.","Use RFC 4180-compliant quoting in source data.","Skip header/footer lines before guessing."],"tags":["kettle","etl","csv-parsing","line-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}