# Issues reading CSV file with array elements

**URL:** <https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747>\
**Category:** General Usage\
**Tags:** dataframes, csv\
**Created:** [September 6, 2021, 12:46pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747 "2021-09-06T12:46:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cevheriferd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cevheriferd/32/26792_2.png) [@Cevheriferd](https://discourse.julialang.org/u/Cevheriferd)\
**Post date:** [September 6, 2021, 12:46pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747/1 "2021-09-06T12:46:25Z")

</div>

The problem is as follows:  
I have a dataframe with a column that has Vector{Float64} elements. When I store the dataframe in a CSV file and then retrieve it, the type of the column changed from Vector{Float64} to String. Which is really annoying since I need the values from within the Vector. A MWE is shown below:

```julia
using DataFrames, CSV

testDF = DataFrame([:columnA => Vector{Vector{Float64}}(undef,1)]) #Column type is Vector{Vector{Float64}}
testDF[1,:columnA] = [1.5,3.2,9.0]
CSV.write("C:\\Users\\Public\\testCSVfile",testDF)
testDF = DataFrame(CSV.File("C:\\Users\\Public\\testCSVfile")) #Column type is String?

```

How can I retain the type of my column?

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 6, 2021, 12:51pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747/2 "2021-09-06T12:51:22Z")

</div>

normally, for types you would want to store in a format that remembers the type like arrow, parquet, or even JDF.jl.

but aren’t you storing an array at row 1 column `:columnA`? that’ seem to be the issue here

---

<div class="post-metadata">

**Author:** ![Cevheriferd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cevheriferd/32/26792_2.png) [@Cevheriferd](https://discourse.julialang.org/u/Cevheriferd)\
**Post date:** [September 6, 2021, 12:56pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747/3 "2021-09-06T12:56:47Z")

</div>

That is the whole point. I want to store an array in the dataframe as an element. JDF seems like a solution, but would it be possible to retrieve the data in the Python programming language? The main reason I use a CSV format is because it is also usable to read the file in Python.

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 6, 2021, 1:04pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747/4 "2021-09-06T13:04:59Z")

</div>

> [@Cevheriferd](#):
>
> an array in the dataframe as an element

ok then the data will be written out as `"[10, 2, 20]"` you need some code to parse that back as array.

So you want it to be read by python? not sure what’s a good, I think maybe arrow. The parquet writer in julia doesn’t do that yet.

so you just write some python code on the other end to parse that back into an array.

---

<div class="post-metadata">

**Author:** ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Post date:** [September 6, 2021, 1:55pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747/5 "2021-09-06T13:55:47Z")

</div>

I have asked more or less the same question a while ago [here](https://discourse.julialang.org/t/dataframes-csv-how-to-read-vectors-from-csv/57883). Maybe some answers are helpful for you.
