# Best way to manage missing data of date type while using bulk to inject data into elasticsearch

**URL:** https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398
**Category:** Elasticsearch
**Created:** [August 8, 2019, 10:25am UTC](https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398 "2019-08-08T10:25:43Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Saurabh\_Sharma\_IIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saurabh_sharma_iit/32/48921_2.png) [@Saurabh\_Sharma\_IIT](https://discuss.elastic.co/u/Saurabh_Sharma_IIT)
#### Post date: [August 8, 2019, 10:25am UTC](https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398/1 "2019-08-08T10:25:43Z")

</div>

Hi, I am trying to inject csv file into elasticsearch. I have a row named "starttime". In this columns some rows are missing. I have converted this to datetime format using pandas to\_datetime. Now when I inject this data into elastic I got the error that empty date `cannot parse empty date'`.  
I found that at that particular row my value is empty string i.e. ''  
How to manage this missing data.  
I have tried putting NaT, NaN but that doesn't work.  
For now I have put interger 0 there and it is working but I am trying to find the best way to mange it.  
Thanks

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [August 9, 2019, 5:52am UTC](https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398/2 "2019-08-09T05:52:20Z")

</div>

I would try to not set this field at all, so it does not get any value assigned and is considered missing.

---

<div class="post-metadata">

### Author: ![Saurabh\_Sharma\_IIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saurabh_sharma_iit/32/48921_2.png) [@Saurabh\_Sharma\_IIT](https://discuss.elastic.co/u/Saurabh_Sharma_IIT)
#### Post date: [August 9, 2019, 6:35am UTC](https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398/3 "2019-08-09T06:35:22Z")

</div>

@spinscale Hi, thanks for your response.  
Actually while saving the raw data into csv, I am using df.to\_csv() and parameter "na\_rep" its default value i.e. ''.  
So how to make missing data assigned to no value in pandas and therefore considered missing.  
I set it to None and tried but that failed and error log is:  
`{'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS`

---

<div class="post-metadata">

### Author: ![Saurabh\_Sharma\_IIT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saurabh_sharma_iit/32/48921_2.png) [@Saurabh\_Sharma\_IIT](https://discuss.elastic.co/u/Saurabh_Sharma_IIT)
#### Post date: [August 11, 2019, 8:09am UTC](https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398/4 "2019-08-11T08:09:59Z")

</div>

Hi, I used ignore\_malformed in mapping and it's kind solve my problem. But still I am looking for other ways to do it.

---

<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: [September 8, 2019, 8:10am UTC](https://discuss.elastic.co/t/best-way-to-manage-missing-data-of-date-type-while-using-bulk-to-inject-data-into-elasticsearch/194398/5 "2019-09-08T08:10:04Z")

</div>

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