# Hi all, I am trying to ingest json file in Elasticsearch using python , but index is not getting created

**URL:** <https://discuss.elastic.co/t/hi-all-i-am-trying-to-ingest-json-file-in-elasticsearch-using-python-but-index-is-not-getting-created/295903>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [February 1, 2022, 6:17am UTC](https://discuss.elastic.co/t/hi-all-i-am-trying-to-ingest-json-file-in-elasticsearch-using-python-but-index-is-not-getting-created/295903 "2022-02-01T06:17:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chinmay\_Bhusate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chinmay_bhusate/32/100952_2.png) [@Chinmay\_Bhusate](https://discuss.elastic.co/u/Chinmay_Bhusate)\
**Post date:** [February 1, 2022, 6:17am UTC](https://discuss.elastic.co/t/hi-all-i-am-trying-to-ingest-json-file-in-elasticsearch-using-python-but-index-is-not-getting-created/295903/1 "2022-02-01T06:17:08Z")

</div>

Code is running , I'm not getting any error . But at a same time index is not created .

Here is my code.

import sys  
import json  
from pprint import pprint  
from elasticsearch import Elasticsearch  
es = Elasticsearch(  
['localhost'],  
port=9200

)

# es = Elasticsearch(host = "localhost", port = 9200)

MyFile= open(r"D:/elastic\_php/test.json",'r').read()  
ClearData = MyFile.splitlines(True)  
i=0  
json\_str=""  
docs ={}  
for line in ClearData:  
line = ''.join(line.split())  
if line != "},":  
json\_str = json\_str+line  
else:  
docs[i]=json\_str+"}"  
json\_str=""  
print(docs[i])  
es.index(index='wiki', doc\_type='doc', id=i, body=docs[i])  
i=i+1

Any solution on this?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2022, 9:55am UTC](https://discuss.elastic.co/t/hi-all-i-am-trying-to-ingest-json-file-in-elasticsearch-using-python-but-index-is-not-getting-created/295903/2 "2022-02-01T09:55:54Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<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:** [March 1, 2022, 9:56am UTC](https://discuss.elastic.co/t/hi-all-i-am-trying-to-ingest-json-file-in-elasticsearch-using-python-but-index-is-not-getting-created/295903/3 "2022-03-01T09:56:05Z")

</div>

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