T-F-S / csvsimple

A LaTeX package for lightweight CSV file processing.
http://www.ctan.org/pkg/csvsimple
LaTeX Project Public License v1.3c
24 stars 5 forks source link

Allow filter appending #24

Closed Krzmbrzl closed 1 year ago

Krzmbrzl commented 1 year ago

Let me start by stating: The possibility to filter input data is superb!

Now, I believe that it would be even more handy if one could append filters. E.g.

\csvreader[
    filter strcmp = {\mycol}{bla},
    filter strcmp = {\myothercol}{blubb},
]{...}{...}

which should essentially become a filter á la

if (mycol == "bla" && myothercol == "blubb") {
    accept
} else {
    reject
}

As it stands, the second invocation of filter strcmp will overwrite the first.

T-F-S commented 1 year ago

Such filtering could be done filter bool, but this needs expl3 syntax.

Your suggestion would be easier to use. But, I would not make the existing filters appending, but rather introduce new options like and filter strcmp:

\csvreader[
    filter strcmp = {\mycol}{bla},
    and filter strcmp = {\myothercol}{blubb},
]{...}{...}

This needs some change of the existing code, but first tests look promising.

Krzmbrzl commented 1 year ago

Such filtering could be done filter bool, but this needs expl3 syntax.

It's also possible with filter expr and etoolbox - that's what I use for the time being.

But, I would not make the existing filters appending, but rather introduce new options like and filter strcmp

Yeah, sounds good to me :+1:

T-F-S commented 1 year ago

New additive filter options added: https://github.com/T-F-S/csvsimple/releases/tag/v2.4.0