# Loading Fixed legth CSV File with Logstash

**URL:** <https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365>\
**Category:** Logstash\
**Created:** [September 5, 2017, 5:08am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365 "2017-09-05T05:08:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KIRAN1205](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@KIRAN1205](https://discuss.elastic.co/u/KIRAN1205)\
**Post date:** [September 5, 2017, 5:08am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/1 "2017-09-05T05:08:14Z")

</div>

Hi,  
I'm new to elasticsearch, i install elasticsearch, logstash now i need to import a fixed legth CSV file and process data to elastic search.  
please can help me in configuration.

thanks in advance

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 5, 2017, 5:47am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/2 "2017-09-05T05:47:19Z")

</div>

Use a file input to read the file, a csv filter to process each line, and an elasticsearch output to send the resulting data to ES.

---

<div class="post-metadata">

**Author:** ![KIRAN1205](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@KIRAN1205](https://discuss.elastic.co/u/KIRAN1205)\
**Post date:** [September 6, 2017, 6:39am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/3 "2017-09-06T06:39:47Z")

</div>

Thanks for reply.Can you please help to separate columns with fixed length.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 6, 2017, 7:28pm UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/4 "2017-09-06T19:28:12Z")

</div>

So there's no column separator at all? Then it's not really CSV. I'm not sure Logstash has a plugin to process fixed-length columns without delimiters, but a ruby filter can certainly do it.

For further help we'll need to see an example.

---

<div class="post-metadata">

**Author:** ![KIRAN1205](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@KIRAN1205](https://discuss.elastic.co/u/KIRAN1205)\
**Post date:** [September 8, 2017, 4:08am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/5 "2017-09-08T04:08:59Z")

</div>

Thanks for Reply.here my example

INPUT Data in file  
01KIRANV1990  
03GIRISH1985

OUT PUT COLUMNS  
Id : FIRST TWO DIGITS  
NAME:3 to 9 (next 6 charcters)  
Year :Lnext 4 characters

## ID NAME Year

01 KIRANV 1990  
03 GIRISH 1985

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 8, 2017, 6:03am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/6 "2017-09-08T06:03:22Z")

</div>

So... no delimiters at all then? You could use a grok filter for this, e.g. with this expression:

```
^(?<id>..)(?<name>.{6})(?<year>.{4})
```

---

<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:** [October 6, 2017, 6:03am UTC](https://discuss.elastic.co/t/loading-fixed-legth-csv-file-with-logstash/99365/7 "2017-10-06T06:03:28Z")

</div>

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