How to use the unicodecsv.UnicodeReader function in unicodecsv

To help you get started, we’ve selected a few unicodecsv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cooperhewitt / solr-whosonfirst / bin / import-cooperhewitt.py View on Github external
#!/usr/bin/env python

import sys
import pysolr
import unicodecsv
import machinetag
import bz2

if __name__ == '__main__':

    people = sys.argv[1]
    fh = bz2.BZ2File(people, 'r')

    reader = unicodecsv.UnicodeReader(fh)
    docs = []

    endpoint = 'http://localhost:8984/solr/whosonfirst'
    solr = pysolr.Solr(endpoint)

    for row in reader:

        doc = {
            'uri': 'x-urn:ch:id=%s' % row['id'],
            'collection': 'cooperhewitt',
            'collection_id': row['id'],
            'name' : row['name']
            }

        concordances = []