Created
October 18, 2018 08:36
-
-
Save kokes/bdeb222298ec3f16704fb70795932217 to your computer and use it in GitHub Desktop.
elasticsearch pro rusky tweety
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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