# Reading a few rows from a BIG CSV file

**URL:** <https://discourse.julialang.org/t/reading-a-few-rows-from-a-big-csv-file/68611>\
**Category:** General Usage\
**Tags:** dataframes, csv, big-data\
**Created:** [September 23, 2021, 2:39am UTC](https://discourse.julialang.org/t/reading-a-few-rows-from-a-big-csv-file/68611 "2021-09-23T02:39:54Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [September 23, 2021, 7:37pm UTC](https://discourse.julialang.org/t/reading-a-few-rows-from-a-big-csv-file/68611/16 "2021-09-23T19:37:10Z")

</div>

Ok, I’m trying this:

```julia

df1 = CSV.read("psam_husa.csv",DataFrame,limit=1)
thetypes = [typeof(df1[1,i]) for i in 1:size(df,2)]

df = Iterators.filter(x-> rand() < .2 && x[:NP] >= 3,CSV.Rows("psam_husa.csv";types=thetypes)) |> DataFrame

```

That failed when it got to some rows that didn’t have correctly detected types. I’m manually setting a few of the types and continuing… will see what happens.

Ok this worked!

```julia

df1 = CSV.read("psam_husa.csv",DataFrame,limit=1)
thetypes = vcat([String,String],[typeof(df1[1,i]) for i in 3:size(df1,2)])

df = Iterators.filter(x-> rand() < .2 && x[:NP] >= 3,CSV.Rows("psam_husa.csv";types=thetypes)) |> DataFrame

```

Took 118 seconds and produced 136k rows… so I guess that’s the solution.

---

_[View the full topic](https://discourse.julialang.org/t/reading-a-few-rows-from-a-big-csv-file/68611)._
