Skip to content

help migrating to CSV v1.0 #1207

Open

Description

@longemen3000

Hello,

If i understand correctly, CSV v1 does not accept functions for the drop argument anymore, in favor of Tables.Scan. one problem with this is that Tables.Scan only works on the actual names of the columns, whereas the function i am using performs a transformation on the column name before the selection procedure.

The function is the following:

function _drop(i,name)
    norm_header = normalisestring(name)
    normalisestring(norm_header; tofilter=r"[ \-\_\d]") ∈ ignorelist #ignorelist is an user-supplied list
end

function normalisestring(str; tofilter = ' ')
    res = Base.Unicode.normalize(str,casefold=true,stripmark=true)
    return replace(res, tofilter => "")
end

what can be done to migrate this workflow to CSV v1?

Activity

  1. quinnj commented on Sep 23, 2026

    @quinnj
    Member

    [PR link description generated by AI]

    Thanks for the report. #1210 brings back function-valued select and drop, and releases them as CSV 1.2.0. After that release, your 0.10 code works again:

    CSV.File(path; drop=_drop)

    As in 0.10, the function receives the column position and the column name as a Symbol. Call String(name) before Unicode.normalize, because normalize does not accept a Symbol.

    Until 1.2.0 is registered, you can compute the mask from the header names first on CSV 1.0 or 1.1:

    using CSV, Tables
    lf = CSV.lazy(path)   # reads the header and builds the structural index once
    mask = [_drop(i, nm) for (i, nm) in enumerate(Tables.columnnames(lf))]
    file = CSV.File(lf; drop=mask)   # parses from the same index

    CSV.File(lf) reuses the index from CSV.lazy, so this costs about the same as one read. For CSV.Rows or CSV.Chunks, get the names with Tables.columnnames(CSV.File(path; limit=0)) and pass the same drop=mask.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions