Answered You can hire a professional tutor to get the answer.

QUESTION

is this code correct for polulating database ?

is this code correct for polulating database ?

import csv

import sqlite3

cur=con.cursor()

  #passenger-data.csv

with open (sys.argv[1] , 'r') as fin:

  csvin=csv.reader(fin)

  passenger_data=[line for line in csvin]#every line a list with strings

  for k in company_data[1:]:

    cur.execute('INSERT OR IGNORE INTO marta(index, date, route_id, direction, stop_id, stop_name, on_number, off_number,vehicle_id ) VALUES(?,?,?,?,?,?,?,?)' , ('index', 'date', 'route_id', 'direction', 'stop_id', 'stop_name', 'on_number', 'off_number','vehicle_id' ))

    cur.execute('INSERT OR IGNORE INTO marta(index, date, route_id, direction, stop_id, stop_name, on_number, off_number,vehicle_id ) VALUES(?,?,?,?,?,?,?,?)' , (k[0],k[1],k[2],k[4],k[5],k[7],k[8],k[9]))

if __name__ == "__main__":

  import sys

  main(sys.argv)

opulate the database

https://www.dropbox.com/s/5yq259rjb8qme7l/passenger_data.csv?dl=0

https://www.dropbox.com/s/h9592ln0y6h5amp/marta-schema.sql?dl=0

  • Develop a python script called import_marta.py that reads in the given csv file and stores the information from the appropriate columns of the csv file into the appropriate table(s) of the database, which you can assume has already been created using your marta-schema.sql script.
  • The name of the csv file and the database will be passed in as command line arguments to your program. Do not hard code the name of the csv file or the database. Your program must be able to read from the csv file whose name is given as the first command line argument and write to the database whose name is given in the second command line argument
  • Your program will be run in the following manner:
$ python import_marta.py passenger_data.csv marta localhost rootPassword for
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question