# FIleBeat import csv file into elasticsearch,but each line was treated as a string, I want each line was spilit by comma

**URL:** <https://discuss.elastic.co/t/filebeat-import-csv-file-into-elasticsearch-but-each-line-was-treated-as-a-string-i-want-each-line-was-spilit-by-comma/62676>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 11, 2016, 1:34am UTC](https://discuss.elastic.co/t/filebeat-import-csv-file-into-elasticsearch-but-each-line-was-treated-as-a-string-i-want-each-line-was-spilit-by-comma/62676 "2016-10-11T01:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liu\_Lantern](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@Liu\_Lantern](https://discuss.elastic.co/u/Liu_Lantern)\
**Post date:** [October 11, 2016, 1:34am UTC](https://discuss.elastic.co/t/filebeat-import-csv-file-into-elasticsearch-but-each-line-was-treated-as-a-string-i-want-each-line-was-spilit-by-comma/62676/1 "2016-10-11T01:34:10Z")

</div>

1. I got a problem when I import csv file into elasticsearch
2. here is my csv file looks like

> name,age,sex  
> amy,18,girl  
> tom,19,boy

1. and I use the default template in /etc/filebeat/filebeat.template.json which is below

> {  
> "mappings": {  
> "_default_": {  
> "\_all": {  
> "enabled": true,  
> "norms": {  
> "enabled": false  
> }  
> },  
> "dynamic\_templates": [  
> {  
> "template1": {  
> "mapping": {  
> "doc\_values": true,  
> "ignore\_above": 1024,  
> "index": "not\_analyzed",  
> "type": "{dynamic\_type}"  
> },  
> "match": "_"  
> }  
> }  
> ],  
> "properties": {  
> "@timestamp": {  
> "type": "date"  
> },  
> "message": {  
> "type": "string",  
> "index": "analyzed"  
> },  
> "offset": {  
> "type": "long",  
> "doc\_values": "true"  
> }  
> }  
> }  
> },  
> "settings": {  
> "index.refresh\_interval": "5s"  
> },  
> "template": "filebeat-_"  
> }

1. the data I got in elasticseach was like

> 1. message: "amy,18,girl"
> 2. message:"tom,19,boy"

1. I want to get the result like below

> 1. {name: "amy", age: 18, sex: "girl"}
> 2. {name: "tom", age: 19, sex: "boy"}

1. So what should I config to get the result( just split the each line by comma when I import the csv file to elasticseach )

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 11, 2016, 3:07am UTC](https://discuss.elastic.co/t/filebeat-import-csv-file-into-elasticsearch-but-each-line-was-treated-as-a-string-i-want-each-line-was-spilit-by-comma/62676/2 "2016-10-11T03:07:44Z")

</div>

You need to use Logstash for that.

---

<div class="post-metadata">

**Author:** ![Liu\_Lantern](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@Liu\_Lantern](https://discuss.elastic.co/u/Liu_Lantern)\
**Post date:** [October 13, 2016, 6:41am UTC](https://discuss.elastic.co/t/filebeat-import-csv-file-into-elasticsearch-but-each-line-was-treated-as-a-string-i-want-each-line-was-spilit-by-comma/62676/3 "2016-10-13T06:41:38Z")

</div>

Thanks Very Much!  
Finally we use Python to import the csv file into elasticsearch.

---

<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:** [November 1, 2016, 1:34am UTC](https://discuss.elastic.co/t/filebeat-import-csv-file-into-elasticsearch-but-each-line-was-treated-as-a-string-i-want-each-line-was-spilit-by-comma/62676/4 "2016-11-01T01:34:12Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
