Skip to content

Instantly share code, notes, and snippets.

@maguec
Created January 19, 2021 23:40
Show Gist options
  • Select an option

  • Save maguec/a2318f9c8b49ebc85df322b3eaffd251 to your computer and use it in GitHub Desktop.

Select an option

Save maguec/a2318f9c8b49ebc85df322b3eaffd251 to your computer and use it in GitHub Desktop.
Load Data using the batch indexer example
#!/usr/bin/env python3
from redisearch import Client, TextField
import csv
client = Client('WPOI',
host='localhost',
password='',
port=6379
)
indexer = client.batch_indexer(chunk_size=1000)
client.create_index((
TextField('TELNUM'),
TextField('HTTP'),
))
phone_chars = ['(', ')', '-', ' ']
with open('./wpoi.csv', encoding='utf-8') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
headers = next(csv_reader, None)
for row in csv_reader:
indexer.add_document(
row[0],
nosave = True,
TELNUM = ''.join(i for i in row[27] if not i in phone_chars),
HTTP = row[30],
)
indexer.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment