import click import ijson.backends.yajl2_cffi as ijson @click.command() @click.option('--index', '-n', default=0, help='Index of CSV.') def build_index(): pass def index_file(fn): with open(fn, 'r') as f: parser = ijson.parse(urlopen('http://.../')) stream.write('') for prefix, event, value in parser: if (prefix, event) == ('earth', 'map_key'): stream.write('<%s>' % value) continent = value elif prefix.endswith('.name'): stream.write('' % value) elif (prefix, event) == ('earth.%s' % continent, 'end_map'): stream.write('' % continent) stream.write('') if __name__ == '__main__': build_index()