# Pivot the field using csv data in LS

**URL:** <https://discuss.elastic.co/t/pivot-the-field-using-csv-data-in-ls/192539>\
**Category:** Logstash\
**Created:** [July 27, 2019, 9:28pm UTC](https://discuss.elastic.co/t/pivot-the-field-using-csv-data-in-ls/192539 "2019-07-27T21:28:42Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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 28, 2019, 5:25pm UTC](https://discuss.elastic.co/t/pivot-the-field-using-csv-data-in-ls/192539/6 "2019-07-28T17:25:53Z")

</div>

The csv output will output empty fields is the event is missing them, so all you really need is

```
    csv { autodetect_column_names => true remove_field => ["message"] }
    ruby { code => 'event.set(event.get("Type"), event.get("Count"))' }

```

The fields option on the filter is not optional, but you could use a technique similar to [this](https://discuss.elastic.co/t/export-to-csv-with-all-fields-logstash-7-0-1/187420/2) to find the set of fields required.

---

_[View the full topic](https://discuss.elastic.co/t/pivot-the-field-using-csv-data-in-ls/192539)._
