You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/08/25 05:59:00 UTC
[jira] [Commented] (GROOVY-12295) CsvSlurper: parsing fails with useHeader=false despite documented auto-generated column names
[ https://issues.apache.org/jira/browse/GROOVY-12295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107673#comment-18107673 ]
ASF GitHub Bot commented on GROOVY-12295:
-----------------------------------------
paulk-asert opened a new pull request, #2831:
URL: https://github.com/apache/groovy/pull/2831
…documented auto-generated column names
> CsvSlurper: parsing fails with useHeader=false despite documented auto-generated column names
> ---------------------------------------------------------------------------------------------
>
> Key: GROOVY-12295
> URL: https://issues.apache.org/jira/browse/GROOVY-12295
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Priority: Major
>
> The javadoc for {{CsvSlurper#parse(Reader)}} states:
> {quote}When {{useHeader}} is false, maps are keyed by auto-generated column names.{quote}
> No such auto-generation exists. With {{useHeader=false}}, any non-empty input fails:
> {code:groovy}
> new groovy.csv.CsvSlurper().setUseHeader(false).parseText('1,2\n3,4')
> {code}
> throws:
> {noformat}
> groovy.csv.CsvRuntimeException
> Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException:
> Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists):
> no String-argument constructor/factory method to deserialize from String value ('1')
> {noformat}
> *Cause:* {{buildSchema()}} with {{useHeader=false}} produces an empty {{CsvSchema}} with no columns. jackson-dataformat-csv then presents each row as an array of strings rather than an object, which cannot bind to {{Map}}, so the entire untyped {{useHeader=false}} path is broken, not just an edge case.
> *Possible resolutions:*
> # Implement the documented behavior: peek at the first row to determine the column count and generate names (e.g. {{column1}}..{{columnN}}), building the schema from those.
> # Return a list of string lists (one per row) when {{useHeader}} is false, and adjust the docs accordingly.
> # Keep current behavior but fix the javadoc and fail fast with a clear error message.
> Since the module is still {{@Incubating}}, any of these can be adopted without compatibility concerns.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)