# Julia appending data to dataframe gives dataframe not defined

**URL:** <https://discourse.julialang.org/t/julia-appending-data-to-dataframe-gives-dataframe-not-defined/24644>\
**Category:** New to Julia\
**Created:** [May 27, 2019, 8:42am UTC](https://discourse.julialang.org/t/julia-appending-data-to-dataframe-gives-dataframe-not-defined/24644 "2019-05-27T08:42:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [May 27, 2019, 8:42am UTC](https://discourse.julialang.org/t/julia-appending-data-to-dataframe-gives-dataframe-not-defined/24644/1 "2019-05-27T08:42:39Z")

</div>

Dear all,  
I am trying to append data to a data frame. I have set an empty dataframe, then made a copy of it, the point is in populate the data frame and rest it by re-copying the empty one. By doing this reiterate, I save the data directly instead of keeping it into memory:

```julia
df = DataFrame(
    column = String[], ...)
CSV.write("df.tsv", df; delim='\t', append=false)
E_df = deepcopy(df)
x = <a subset of a dataframe with the same columns as df>
append!(df, x)
CSV.write"df.tsv", df; delim='\t', append=ftrue)
 df = deepcopy(E_df)

```

But I get the error  
`UndefVarError: df not defined `  
But then if I call the dataframe:

```julia
julia> df
4×8 DataFrame. Omitted printing of 2 columns
...

```

If I try push!(df, x) I get `MethodError: no method matching iterate (::DataFrame)` although the package DataFrames is loaded.  
What am I getting wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 27, 2019, 11:04am UTC](https://discourse.julialang.org/t/julia-appending-data-to-dataframe-gives-dataframe-not-defined/24644/2 "2019-05-27T11:04:01Z")

</div>

> [@Luigi\_Marongiu](#):
>
> ```julia
> CSV.write"df.tsv", df; delim='\t', append=ftrue)
> 
> ```

There is a missing `(` after `write`.

> [@Luigi\_Marongiu](#):
>
> What am I getting wrong?

Hard to say without a MWE.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …
