original_docstring: 
      Mass import csv into SQLite database.
      
      Inspired by https://stackoverflow.com/a/2888042/8500344
      
      - cursor: a database cursor to execute SQL queries
      
docstring: Mass import csv into SQLite database.
  
  a database cursor to execute SQL queries
docstring_tokens: Mass import csv into SQLite database . a database cursor to execute SQL queries
code: def import_csv_into_sqlite(cursor):
      """
      Mass import csv into SQLite database.
      
      Inspired by https://stackoverflow.com/a/2888042/8500344
      
      - cursor: a database cursor to execute SQL queries
      """
      for table, columns in [('nodes', ['osmid', 'latitude', 'longitude', 'userid']),
                             ('nodes_tags', ['node_id', 'key', 'value']),
                             ('ways', ['osmid', 'userid']),
                             ('ways_tags', ['way_id', 'key', 'value']),
                             ('ways_nodes', ['way_id', 'node_id']),
                             ('relations', ['osmid', 'userid']),
                             ('relations_tags', ['relation_id', 'key', 'value']),
                             ('relations_nodes', ['relation_id', 'node_id']),
                             ('relations_ways', ['relation_id', 'way_id']),
                             ('relations_relations', ['relation_container', 'relation_content'])]:
          with open('{}.csv'.format(table)) as fobj:
              print "Importing {}.csv [{} bytes]...".format(table, os.path.getsize("{}.csv".format(table))),
              reader = csv.DictReader(fobj)
              script = "INSERT INTO {} ({}) VALUES ({})".format(
                  table, ",".join(columns), ",".join(map(lambda x: '?', columns)))
              to_db = [[row[col].decode('utf-8') for col in columns] for row in reader]
              cursor.executemany(script, to_db)
              print "done"
code_tokens: def import_csv_into_sqlite ( cursor ) : for table , columns in [ ( 'nodes' , [ 'osmid' , 'latitude' , 'longitude' , 'userid' ] ) , ( 'nodes_tags' , [ 'node_id' , 'key' , 'value' ] ) , ( 'ways' , [ 'osmid' , 'userid' ] ) , ( 'ways_tags' , [ 'way_id' , 'key' , 'value' ] ) , ( 'ways_nodes' , [ 'way_id' , 'node_id' ] ) , ( 'relations' , [ 'osmid' , 'userid' ] ) , ( 'relations_tags' , [ 'relation_id' , 'key' , 'value' ] ) , ( 'relations_nodes' , [ 'relation_id' , 'node_id' ] ) , ( 'relations_ways' , [ 'relation_id' , 'way_id' ] ) , ( 'relations_relations' , [ 'relation_container' , 'relation_content' ] ) ] : with open ( '{}.csv' . format ( table ) ) as fobj : print "Importing {}.csv [{} bytes]..." . format ( table , os . path . getsize ( "{}.csv" . format ( table ) ) ) , reader = csv . DictReader ( fobj ) script = "INSERT INTO {} ({}) VALUES ({})" . format ( table , "," . join ( columns ) , "," . join ( map ( lambda x : '?' , columns ) ) ) to_db = [ [ row [ col ] . decode ( 'utf-8' ) for col in columns ] for row in reader ] cursor . executemany ( script , to_db ) print "done"
short_docstring: Mass import csv into SQLite database.
short_docstring_tokens: Mass import csv into SQLite database .
comment: """
      Mass import csv into SQLite database.
      
      Inspired by https://stackoverflow.com/a/2888042/8500344
      
      - cursor: a database cursor to execute SQL queries
      """