# Functionality like tidyverse's any\_of()?

**URL:** <https://discourse.julialang.org/t/functionality-like-tidyverses-any-of/128293>\
**Category:** Data\
**Tags:** dataframes\
**Created:** [April 22, 2025, 11:19am UTC](https://discourse.julialang.org/t/functionality-like-tidyverses-any-of/128293 "2025-04-22T11:19:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [April 22, 2025, 11:19am UTC](https://discourse.julialang.org/t/functionality-like-tidyverses-any-of/128293/1 "2025-04-22T11:19:39Z")

</div>

Is there any way to achieve functionality like [tidyverse’s `any_of()`](https://tidyselect.r-lib.org/reference/all_of.html)?

My use case is that I am reading only certain columns of a file, but there could be columns specified in the call, but non-existent in the file:

```julia
vars = ["one", "two", "three"] # column two does not exist in the file
df = read_csv(file, col_select=any_of(vars))

```

---

<div class="post-metadata">

**Author:** ![eteppo](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@eteppo](https://discourse.julialang.org/u/eteppo)\
**Post date:** [April 22, 2025, 12:26pm UTC](https://discourse.julialang.org/t/functionality-like-tidyverses-any-of/128293/2 "2025-04-22T12:26:41Z")

</div>

For this specific use case, `CSV.read` ([Reading · CSV.jl](https://csv.juliadata.org/stable/reading.html#CSV.read)) seems to accept keyword arguments `select` or `drop` that take a vector of column names (strings or symbols), positions (integers), or booleans ([examples](https://csv.juliadata.org/stable/examples.html#select_example)) in a way that invalid column names are just ignored.

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [May 1, 2025, 2:30pm UTC](https://discourse.julialang.org/t/functionality-like-tidyverses-any-of/128293/3 "2025-05-01T14:30:36Z")

</div>

```julia
using CSV

data = """
a,b,c
1,2,3
4,5,6
7,8,9
"""

vars = Symbol.(["a","g","c"])

file = CSV.File(IOBuffer(data); select=(i, name) -> name in vars)

# output:

3-element CSV.File:
 CSV.Row: (a = 1, c = 3)
 CSV.Row: (a = 4, c = 6)
 CSV.Row: (a = 7, c = 9)

```
