From 1a5effec286e4753dfdd8e8279abbbdf1ce8e0d2 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Nov 2018 21:35:09 +0100 Subject: s2 scripts --- s2-index.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 s2-index.py (limited to 's2-index.py') diff --git a/s2-index.py b/s2-index.py new file mode 100644 index 00000000..779f63a5 --- /dev/null +++ b/s2-index.py @@ -0,0 +1,24 @@ +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() -- cgit v1.2.3-70-g09d2