Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I NEED HELP WITH THIS PYTHON ASSIGNMENT (TEXTBOOK SOLUTION IS INCORRECT) Spreads

ID: 3847796 • Letter: I

Question

I NEED HELP WITH THIS PYTHON ASSIGNMENT (TEXTBOOK SOLUTION IS INCORRECT)

Spreadsheet programs such as Microsoft Excel or OpenOffice Calc have an option to export data into CSV files. In this exercise, you will create a program that will read in a spreadsheet (in CSV format) and manipulate it. Provide the following capabilities:

Print the data.

Delete a row or column

Insert a row or column.

Change a value in a cell.

Output the data in CSV format.

Issues to consider:

Use Python's csv module to read in a spreadsheet. Choose an appropriate data structure to store the data. Should you use lists, tuples or dictionaries?

Construct a driving loop in your program that will prompt for the operations specified previously. A useful interface is to allow choices to be specified with a single letter related to the operation - e.g. for delete.

EXAMPLE FOR PROBLEM:

Use the following sample code to get you started with a csv file https://repl.it/I9Xe/2

Explanation / Answer

inputfile.insert(loc=3, column='ColD', value='NewVal')

#Removing column

inputfile.drop(labels=['ColE'], axis=1, inplace=True)

idx = len(inputfile)

inputfile.loc[idx] = [7,8,9]

#Updating based on criterion

inputfile.loc[ inputfile.ColB%2 == 0, 'ColC' ] = 10

#Deleting rows based on some criterion

inputfile = inputfile[ inputfile.ColC == 10 ]

# writing data to csv

writer = csv.writer(inputfile, delimiter='', quotechar='"', quoting=csv.QUOTE_ALL)

for row in reader:

    writer.writerow(row)