Disclaimer: I have not had any training in Python. I have learnt HTML, CSS, C but many years ago and don't remember much.
I am doing a HW for a chemical engineering class. The questions asks to a) create a csv file using python and input the given data. Each row of the csv should contain data of one distribution with the first row of the csv file havng the word "grade" b) read the said csv file and store the data and store this data in an array and c) create an histogram
the code I wrote was:
import csv
with open('data.csv', 'w', newline='') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=' ',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(['Grade'])
spamwriter.writerow(['40'])
spamwriter.writerow(['60,60,60'])
spamwriter.writerow(['80,80,80,80'])
spamwriter.writerow(['100,100'])
import csv
results = []
with open("data.csv") as csvfile:
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC) # change contents to floats
for row in imdb_data: # each row is a list
results.append(row)
For this code, it works if the "grade" data row is not there as this is a float. Anyone know how to skip this line of code? I was thinking if there was a command like row+1 or a for loop which can skip it but don't know how to implement it.