I tried to transform the creation of my database Elasticsearch, a script, in an object-oriented format but then create the database by instantiating it in the Main.py
, and nothing else is passed:
Main.py :
from Elastic import Elastic
el = Elastic()
print("server is ready")
Elastic.py :
import csv
import glob
import os
from elasticsearch import helpers, Elasticsearch
class Elastic:
def __init__(self):
es = Elasticsearch()
for path in glob.glob("*.csv"):
with open(path, newline='') as csvfile:
reader = csv.DictReader(csvfile, delimiter=';', quotechar='|')
csv_name = os.path.splitext(path)[0]
helpers.bulk(es, reader, index="index1", doc_type=csv_name)
But I get teh following message which don't seem to instantiate teh last object I tried to add :
You can find the data I try to add here
Annex :
- the whole git repository is here
- the ./elasticsearch terminal message after I tried to instantiate elasticsearch
- the python3 Main.py terminal message