# Reading part of csv file

**URL:** <https://discourse.nodered.org/t/reading-part-of-csv-file/6987>\
**Category:** General\
**Created:** [18 January 2019 19:04 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987 "2019-01-18T19:04:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![15green](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@15green](https://discourse.nodered.org/u/15green)\
**Post date:** [18 January 2019 19:04 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/1 "2019-01-18T19:04:04Z")

</div>

Another newbie question. How do I read only part of a csv file, say the last 10 lines? File node reads the whole file, and tail only the last. There must be a simple way!

---

<div class="post-metadata">

**Author:** ![JayDickson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaydickson/32/90592_2.png) [@JayDickson](https://discourse.nodered.org/u/JayDickson)\
**Post date:** [18 January 2019 19:08 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/2 "2019-01-18T19:08:50Z")

</div>

`tail -n 10 filename.csv` in an exec node should return the last 10 lines.

---

<div class="post-metadata">

**Author:** ![15green](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@15green](https://discourse.nodered.org/u/15green)\
**Post date:** [18 January 2019 23:12 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/3 "2019-01-18T23:12:42Z")

</div>

Thanks @JayDickson that is working. Are there extra parameters I can use to better format the string and separate the lines when using text node on dashboard?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 January 2019 00:24 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/4 "2019-01-19T00:24:54Z")

</div>

If you can add the header row back on, you can simply use the csv node to turn it into JSON.

---

<div class="post-metadata">

**Author:** ![15green](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@15green](https://discourse.nodered.org/u/15green)\
**Post date:** [19 January 2019 13:53 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/5 "2019-01-19T13:53:35Z")

</div>

I'm sure you're right @TotallyInformation but can you explain what that means?!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 January 2019 14:21 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/6 "2019-01-19T14:21:46Z")

</div>

The first row of a csv generally defines the column/field structure. Though I seem to remember you can supply this separately in the CSV node. So perhaps you don’t need to do anything other than define the columns.

The rest of the answer is provided by Jay’s `tail` response.

---

<div class="post-metadata">

**Author:** ![15green](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@15green](https://discourse.nodered.org/u/15green)\
**Post date:** [19 January 2019 16:24 UTC](https://discourse.nodered.org/t/reading-part-of-csv-file/6987/7 "2019-01-19T16:24:05Z")

</div>

ok, yes the tail works fine. My csv doesn't have (or need) any headers, and I don't mind the commas in the text, but I do need each line to display as separate lines. Thanks.
