# Vcat and plot behavior inside Julia script

**URL:** <https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720>\
**Category:** General Usage\
**Created:** [May 7, 2021, 2:03pm UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720 "2021-05-07T14:03:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![scotttbecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scotttbecker/32/24867_2.png) [@scotttbecker](https://discourse.julialang.org/u/scotttbecker)\
**Post date:** [May 7, 2021, 2:03pm UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720/1 "2021-05-07T14:03:22Z")

</div>

Hi all,  
I must be doing something wrong. I can’t get vcat and plot to work inside a script. When I use them in the terminal the commands work fine but inside a script vcat returns no error and an empty dataframe. Plot has a similar behavior. No response inside a script but in the terminal works fine.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 7, 2021, 3:14pm UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720/2 "2021-05-07T15:14:51Z")

</div>

Please read the guidelines [here](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) and post a MWE. Thank you.

---

<div class="post-metadata">

**Author:** ![scotttbecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scotttbecker/32/24867_2.png) [@scotttbecker](https://discourse.julialang.org/u/scotttbecker)\
**Post date:** [May 7, 2021, 9:36pm UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720/3 "2021-05-07T21:36:03Z")

</div>

b\_d = string(Date(begin\_date, “mm/dd/yyyy”))

```
    e_d = string(Date(end_date, "mm/dd/yyyy"))

    global s_d_df = DataFrame(underlying_symbol = [], quote_datetime = [], open = [], high = [], low = [], close = [], trade_volume = [], vwap = [], bid = [], ask = [])

    global tmp_stock_df = DataFrame()

    # Get the file list from the data directory

    global file_list = glob("*3600*.csv", path)

    # Filter to select csv files

    # File names include the date, sort from earliest date to latest

    sort!(file_list)

    # Extract the file names associated with the date timeline from the file list

    start_row_num = findfirst(x -> occursin(b_d, x), file_list)

    len = length(file_list)

    last_file = file_list[len]

    end_file_date = Date(last_file[31:40])

    if Date(e_d) > end_file_date

        e_d = Dates.format(end_file_date, "yyyy-mm-dd")

    end

    end_row_num = findfirst(x -> occursin(e_d, x), file_list)

    f_l = file_list[start_row_num:end_row_num]

    # Build a dataframe containing the data

    len = length(f_l)

    tmp_stock_df = DataFrame(CSV.File(f_l[1]))

    vcat(s_d_df, tmp_stock_df)

    println(s_d_df)

    for i = 2:len

        tmp_stock_df = DataFrame(CSV.File(f_l[i]))

        tmp_stock_df.quote_datetime = map((x) -> DateTime(x, "yyyy-mm-dd HH:MM:SS"), tmp_stock_df.quote_datetime)

        DataFrames.vcat(s_d_df, tmp_stock_df)

    end

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 7, 2021, 11:23pm UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720/4 "2021-05-07T23:23:44Z")

</div>

Your code does not run.  
There is no plot command.  
Include all packages being used.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [May 7, 2021, 11:52pm UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720/5 "2021-05-07T23:52:45Z")

</div>

> [@scotttbecker](#):
>
> `vcat(s_d_df, tmp_stock_df)`

This is suspicious and probably not what you actually want. `vcat` creates a _new_ array (or data frame) with the concatenated result and returns it. Since you’re not using that returned value, it has no effect at all.

You need something like:

```julia
result = vcat(s_d_df, tmp_stock_df)

```

where `result` will now hold the concatenated output.

---

<div class="post-metadata">

**Author:** ![scotttbecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scotttbecker/32/24867_2.png) [@scotttbecker](https://discourse.julialang.org/u/scotttbecker)\
**Post date:** [May 8, 2021, 12:37am UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720/6 "2021-05-08T00:37:00Z")

</div>

Ok. That worked. Thank you. More on plot later.
