Question: Can someone proficient in Python and SQLite help me with this problem? I have posted this several times on Chegg, but nobody has helped. See

Can someone proficient in Python and SQLite help me with this problem? I have posted this several times on Chegg, but nobody has helped.

See the CSV file formats at the bottom of the problem that are mentioned in this problem:

Can someone proficient in Python and SQLite help me with this problem?

The format of the Company Data CSV looks like this:

I have posted this several times on Chegg, but nobody has helped.

The format of the Stock Price CSV looks like this:

See the CSV file formats at the bottom of the problem that

Here is what I have completed so far for Part 1, company-schema.sql, using SQLite:

create table company ( ticker text primary key, name text, sic int, addr1 text, addr2 text, city text, state text, zip int,

foreign key (sic) references sector(sic) );

create table sector ( sic int primary key, name text );

create table stock_price ( ticker text, day text, open float(8), high float(8), low float(8), close float(8), adj_close float(8), volume int,

primary key (ticker, day) );

I just don't know how to do Part 2 and Part 3. Thanks so much.

Solution Description Create a database to hold company data, write a Python script that reads CSV files containing various company data and inserts that data into a database, and write SOL queries that answer various questions about the data in your database Part 1: Create Company Database Write a database creation script named company-schema.sql with create table statements that create a database with the following tables company with fields ticker, name, sic, addri, addr2, city, state, and zip o ticker should be the primary key o sic should be a forelgn key referencing the sector table sector with fields sic, name sic should be the primary key o name comes from the Sector field in the source CSV file stock price with fields ticker, date, open, high, low, close, adj_close, volume ( ticker , date ) should be the (composite) primary key To develop and test your work on the remainder of this assignment you should run your company-schema.sql script to create an SQLite database stored in a file such as company.db Part 2: Import CSV Data in to Company Database Write a python script called import_companies.py that reads a CSV company data file such as the one you created in HW3 and stock price CSV files named after each company's ticker symbol - such as the ones you used in HW2 and inserts the data from those files into a database created with the database creation script you wrote in Part 1 Your script should take as its first command line argument the name of a CSV file containing compnay infomation with the following header line (from HW3) Ticker,Name, SIC,Sector, Addr1,Addr2,City, State,Zip and the second command line argument to your script should be the name of an SQLite database file created from the database creation script you wrote in Part 1. For each record in the CSV file your script should Insert the approriate information from the record into the company and sector tables of the database o Note that many companies will have the same sector. There should be only one sector record for each sector in the sector table Open the CSV file named for the company's ticker symbol. For each record in the stock data CSV file, insert an appropriate record in the stock_price table of the database. Sample program run: python import-companies.py company-data.csv company.db Part 3: Query Company Database Write a file named company-queries.sql with SQL queries that answer the following questions: Which company has the highest stock price as of 1 September, 2017? Which company or companies have had the highest volume of trading during 2016? How may companies in the database are in each sector? What is the average stock price of companies in each sector as of 1 September, 2017

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!