Skip to content

Instantly share code, notes, and snippets.

@kokes
Created October 18, 2018 08:36
Show Gist options
  • Save kokes/bdeb222298ec3f16704fb70795932217 to your computer and use it in GitHub Desktop.
Save kokes/bdeb222298ec3f16704fb70795932217 to your computer and use it in GitHub Desktop.
elasticsearch pro rusky tweety
import csv
import json
import glob
from elasticsearch import Elasticsearch
from elasticsearch.helpers import parallel_bulk, bulk
def get_data():
with open('ira_tweets_csv_hashed.csv') as f:
cr = csv.DictReader(f)
for j, ln in enumerate(cr):
yield {
"_index": "ira",
"_type": "tweet",
"_id": ln['tweetid'],
"_source": dict(ln)
}
es = Elasticsearch()
bulk(es, get_data())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment