Skip to content

readCSV does not produce an array convertable to query when firstRowHeader is off #443

Description

@Daemach

The normal functionality of spreadsheet-cfml is to return a query with column1,column2,columnN as headers if the first row isn't used. But readCSV produces an empty column array in this case, which prevents deserializeJson( serializeJson( result ), false ) from working properly. An empty column array would be ignored normally, so it seems safe to populate this with column1,column2,columnN as headers if the first row isn't used.

Activity

  1. cfsimplicity commented on Nov 18, 2025

    @cfsimplicity
    Owner

    CFML queries must have column names, which is why the library will generate them if the source spreadsheet doesn't have them.

    But CSVs don't have to have headers/columns and I think the result should represent the contents of the CSV as closely as possible.

    I understand the problem if you ultimately want a query object, but in that case you should probably use csvToQuery() instead.

    Your suggestion would be a breaking change. You might think it would be safe, but other folks might be relying on those empty columns, which as I say matches the csv input.

    Having said that, I have wondered whether to include the query de/serialization as an option, which would mean csvToQuery() could be deprecated... In other words add intoAQuery() as a chainable option. That would require auto generation of columns if they were missing. Thoughts?

  2. Daemach commented on Nov 18, 2025

    @Daemach
    Author

    csvToQuery() does not allow me to skip rows.

  3. Daemach commented on Nov 18, 2025

    @Daemach
    Author

    Jumping between meetings. intoAQuery() seems like a workable solution.

  4. cfsimplicity commented on Nov 18, 2025

    @cfsimplicity
    Owner

    OK, John, I'll see what I can do.

  5. cfsimplicity commented on Nov 19, 2025

    @cfsimplicity
    Owner

    @Daemach I've added support for intoAQuery() to the dev branch. Can you test it out please? See examples in the test suite:

    describe( "readCsv() into a query object", ()=>{

  6. Daemach commented on Nov 19, 2025

    @Daemach
    Author

    It works. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions