Graduate Student here: Using Python programming language preferablly Python 3 (U
ID: 3790221 • Letter: G
Question
Graduate Student here:
Using Python programming language preferablly Python 3 (Using any package for i.e Pandas to show graphs)
Create a program that imports a (CSV) file, converts it into XLSX (Excel file) format and outputs a graph (for example you can use Pandas or Matplotlib to create graphs) you'd be using the CSV file whose link is given the graph should compare at least 2 or 4 different values (you decide which ones you can chose any to your liking) in the CSV file and must be able to generate a graph off of that data in the XLSX file given
CSV File Link - https://www.dropbox.com/s/np27ad1np39cssg/Excel%20Heavily%20Modded%20CSV.csv?dl=0
Paste your code as the answer to this question with a screenshot of the code also to prove it worked.
Explanation / Answer
use the below two import functions:
import csv
import matplotlib.pyplot as plt
For reading the csv file:
import CSV
With open(‘some.csv’, ‘rb’) as f:
reader = csv.reader(f)
for row in reader:
print row
for converting the csv to xlsx:
import csv
from xlsxwriter.workbook import Workbook
for csvfile in (give the path)
workbook = Workbook(csvfile + '.xlsx')
worksheet = workbook.add_worksheet()
with open(csvfile, 'rb') as f:
reader = csv.reader(f)
for r, row in enumerate(reader):
for c, col in enumerate(row):
worksheet.write(r, c, col)
workbook.close()
for plotting the graph:
import matplotlib.pyplot as plt
(use the putput from the above code)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.