# Reading multiple CSV file with multiple header

**URL:** <https://discuss.elastic.co/t/reading-multiple-csv-file-with-multiple-header/191582>\
**Category:** Logstash\
**Created:** [July 22, 2019, 6:39am UTC](https://discuss.elastic.co/t/reading-multiple-csv-file-with-multiple-header/191582 "2019-07-22T06:39:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Makra](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Makra](https://discuss.elastic.co/u/Makra)\
**Post date:** [July 22, 2019, 6:39am UTC](https://discuss.elastic.co/t/reading-multiple-csv-file-with-multiple-header/191582/1 "2019-07-22T06:39:02Z")

</div>

Hi

I am trying to read multiple CSV file(bulk) those contains multiple headers. The no of column and their names are dynamic. While parsing the CSV files, I don't want to loose mapping between column header and the corresponding data fields through CSV filter.

What i have found from this [discussion](https://discuss.elastic.co/t/reading-the-heading-1st-line-of-csv-file-through-logstash/108930/5) that logstash is unable to keep mapping between file path and the corresponding header/data values since it is stateless.

```
CSV1
-------

A B C
Data A Data B DATA C

CSV2
--------

D E F G
Data D Data E DATA F DATA G

CSV1000
------------

ZA ZB           
Data ZA Data ZB

```

Considering above CSV files, is it really possible to read and parse all of them in bulk and  
still maintains mapping between column header and data field like following-

```
A : Data A             
B : Data B
C : Data C          
D : Data D
E : Data E
F : Data F
...
...
ZA : Data ZA 
ZB : Data ZB

```

I will appreciate if some one provides some insights on it.  
Regards

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 22, 2019, 12:04pm UTC](https://discuss.elastic.co/t/reading-multiple-csv-file-with-multiple-header/191582/2 "2019-07-22T12:04:57Z")

</div>

Take a look at [this](https://discuss.elastic.co/t/using-ruby-to-count-the-number-of-fields-in-a-message-then-apply-csv-depending-on-the-count/177880/2).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 19, 2019, 12:04pm UTC](https://discuss.elastic.co/t/reading-multiple-csv-file-with-multiple-header/191582/3 "2019-08-19T12:04:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
