# CSV, DataFrame read data file with string and Float64 columns

**URL:** <https://discourse.julialang.org/t/csv-dataframe-read-data-file-with-string-and-float64-columns/118980>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [September 3, 2024, 9:40am UTC](https://discourse.julialang.org/t/csv-dataframe-read-data-file-with-string-and-float64-columns/118980 "2024-09-03T09:40:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiu-Lei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiu-lei/32/211765_2.png) [@Xiu-Lei](https://discourse.julialang.org/u/Xiu-Lei)\
**Post date:** [September 3, 2024, 9:40am UTC](https://discourse.julialang.org/t/csv-dataframe-read-data-file-with-string-and-float64-columns/118980/1 "2024-09-03T09:40:46Z")

</div>

I would like to read this data file [first row is title], containing string in the first column, and float64 in the following columns,  
"  
id a_Mphi a_Moctet a\*Mdecuplet  
A651 0.27507 0.00087 0.6715 0.0044 0.8033 0.0063  
A652 0.2140 0.0010 0.5842 0.0041 0.689 0.013  
A650 0.1835 0.0013 0.5469 0.0054 0.663 0.013  
"

I try to use the following commander to read the data,  
CSV.read(“CLS\_2023\_Tab17.dat”, DataFrame; header=true)

however, I got a 3X1 “string” matrix, how can I get 3X7 matrix?

If possible, can i skip the first column, and just read the Float64 in the dataframe, and have a 3X6 Float64 matrix?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [September 3, 2024, 9:52am UTC](https://discourse.julialang.org/t/csv-dataframe-read-data-file-with-string-and-float64-columns/118980/2 "2024-09-03T09:52:07Z")

</div>

If the column delimiter is a space you can try this:

```julia
df=CSV.read("CLS_2023_Tab17.dat", DataFrame; header=true, delim=" ", drop=[1])

```

You get a warning because your header line only has 4 entries.

---

<div class="post-metadata">

**Author:** ![Xiu-Lei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiu-lei/32/211765_2.png) [@Xiu-Lei](https://discourse.julialang.org/u/Xiu-Lei)\
**Post date:** [September 3, 2024, 10:09am UTC](https://discourse.julialang.org/t/csv-dataframe-read-data-file-with-string-and-float64-columns/118980/3 "2024-09-03T10:09:01Z")

</div>

Thanks! the delim=" " does not work in this case. Because there are several random spaces between columns. Then, I change the datafile by including the “,” between columns, then works for my case.

df=CSV.read(“CLS\_2023\_Tab17.dat”, DataFrame; header=true, delim=“,”, drop=[1])

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [September 3, 2024, 10:13am UTC](https://discourse.julialang.org/t/csv-dataframe-read-data-file-with-string-and-float64-columns/118980/4 "2024-09-03T10:13:57Z")

</div>

Or you use `ignorerepeated` like :

```julia
julia> df=CSV.read("CLS_2023_Tab17.dat", DataFrame;
       header=true, delim=" ", drop=[1], ignorerepeated=true)

```

Check out:

```julia
julia> ?CSV.read

```
