0

I have a csv Excel data set which is related to Some Coivid-19 stats organised with headings and values under for example number of covid related deaths and the numbers under. The goal is to get the values and then calculate the averages of the columns.

The query is how can I open the csv file from Python thonny and calculate the averages of the columns. without using "Import csv" or any other modules such as panda.

this is what I have got so far.

with open(r'C:\Users\Kaoma Kabange\Documents\CITS1401\LAB0\Covid-data-for-project_1_sample (1).csv','r') as f:
f_contents = f.read()
print(f_contents)

I have searched everywhere to find a solution, but most YouTube video's i watch used import csv,panda or other modules. just looking to be pointed in the right direction :)!

this link below is an example of the data set.

https://i.stack.imgur.com/ksxEi.png

Kaoma.K
  • 11
  • 1
  • This is probably already answered [here](https://stackoverflow.com/a/55404281/8277795). – Anurag Dhadse Apr 07 '21 at 06:42
  • You can just read the file as you would any text file then parse the string yourself. `with open('my_file.csv') as f: file_string = f.read() ` – vodbeke Apr 07 '21 at 06:44
  • @Anurag That solution won't work if the data contains the separator in quoted strings. – Bill Huang Apr 07 '21 at 06:45
  • If so why do you don't want to use pandas.read_excel method. Can you provide an example set of the csv file. – Anurag Dhadse Apr 07 '21 at 06:50
  • Hey @AnuragDhadse I just want to try and do it without those libraries, because that is what is specified for the task. And I have attached the sample image above^. – Kaoma.K Apr 07 '21 at 08:30
  • and thanks @vodbeke i tried that and it returned my whole data set which is the first great ! thanks. – Kaoma.K Apr 07 '21 at 08:31

0 Answers0