# Update the last line while writing the current line during writing to a file in julia

**URL:** <https://discourse.julialang.org/t/update-the-last-line-while-writing-the-current-line-during-writing-to-a-file-in-julia/31899>\
**Category:** General Usage\
**Created:** [December 5, 2019, 11:15am UTC](https://discourse.julialang.org/t/update-the-last-line-while-writing-the-current-line-during-writing-to-a-file-in-julia/31899 "2019-12-05T11:15:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [December 5, 2019, 11:15am UTC](https://discourse.julialang.org/t/update-the-last-line-while-writing-the-current-line-during-writing-to-a-file-in-julia/31899/1 "2019-12-05T11:15:54Z")

</div>

Hi. I need to create a file with four columns, say startTimes, startLocs, routeNds, and edgesTravelTimes. Because each column has different length, I figured that I can only use a normal txt file, or a csv file, without using DataFrames. The tricky part is, I need to create/write the file line by line. By the time I was writing the current line, the last two entries of the precious line might need to be updated. I was wondering, would this be possible? Any comments are greatly appreciated.

---

<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:** [December 5, 2019, 11:33am UTC](https://discourse.julialang.org/t/update-the-last-line-while-writing-the-current-line-during-writing-to-a-file-in-julia/31899/2 "2019-12-05T11:33:09Z")

</div>

> [@bsnyh](#):
>
> each column has different length

I don’t think that anything tabular like CSV is the right format then. Depending on the element types, consider JSON, BSON, or JLD2, and just write out a bunch of vectors.

If you really do want a tabular format, just pad the vectors to have equal length and use dataframes.
