this is my code so far but it its not accurate, not sure if i should def  function and then for loop?    import csv with open ('TopUni.csv', mode='r') as csv_file:     csvReader = csv.reader(csv_file)     line = []     for line in csvReader:         sum(line)         print(line)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

this is my code so far but it its not accurate, not sure if i should def  function and then for loop? 

 

import csv

with open ('TopUni.csv', mode='r') as csv_file:
    csvReader = csv.reader(csv_file)

    line = []
    for line in csvReader:
        sum(line)
        print(line)

I was given two CSV files TopUni.csv and capitals.csv, for the first file (TopUni) I have to create a
function that will read the csv file And sum the total of universities in this CSV file in the column.
Add the total which should be 100 but am having some difficulty because they are strings with
names, I don't know if which other way I should do this.
The function should be called univRanking.getInformation (TopUni.csv) as the parameter.
Once I have the sum I need to print it to a textfile.txt for the output to look like this
You need to show the total number of the universities in the TopUni.csv file. The output should be Total
number of universities => $$$where the $$$ should be replaced by the total number of the universities. The
following
an
example
output:
output.txt
Total number of universities => 2000
I cannot use PANDAs I need to write script based on module.
The exact instructions say
You are asked to create one Python file: univRanking.py
Calls the one function from your module as follows:
univRanking.getInformation(selected Country, "TopUni.csv", "capitals.csv")
o The function name MUST BE getinformation and pay attention to the case.
o The second parameter is the ranking file name which is set by default to "TopUni.csv"
In topUNi - Quality of Education Rank --> NOT Used Alumni Employment Rank --> NOT Used Ⓒ
Quality of Faculty Rank --> NOT Used Research Performance Rank --> NOT Used
o The third parameter is the capitals file name which is set by default to "capitals.csv"
The getInformation function will extract all the required information according to the
specifications explained in the previous section and store this information in the
output.txt file according to the exact
univRanking.py This file name and should contain all your work.
In this file you need to write a set of functions that will help you complete the requirement of
the homework. The main objective is to read the content of the two .csv files and display
information extracted from these files.
Transcribed Image Text:I was given two CSV files TopUni.csv and capitals.csv, for the first file (TopUni) I have to create a function that will read the csv file And sum the total of universities in this CSV file in the column. Add the total which should be 100 but am having some difficulty because they are strings with names, I don't know if which other way I should do this. The function should be called univRanking.getInformation (TopUni.csv) as the parameter. Once I have the sum I need to print it to a textfile.txt for the output to look like this You need to show the total number of the universities in the TopUni.csv file. The output should be Total number of universities => $$$where the $$$ should be replaced by the total number of the universities. The following an example output: output.txt Total number of universities => 2000 I cannot use PANDAs I need to write script based on module. The exact instructions say You are asked to create one Python file: univRanking.py Calls the one function from your module as follows: univRanking.getInformation(selected Country, "TopUni.csv", "capitals.csv") o The function name MUST BE getinformation and pay attention to the case. o The second parameter is the ranking file name which is set by default to "TopUni.csv" In topUNi - Quality of Education Rank --> NOT Used Alumni Employment Rank --> NOT Used Ⓒ Quality of Faculty Rank --> NOT Used Research Performance Rank --> NOT Used o The third parameter is the capitals file name which is set by default to "capitals.csv" The getInformation function will extract all the required information according to the specifications explained in the previous section and store this information in the output.txt file according to the exact univRanking.py This file name and should contain all your work. In this file you need to write a set of functions that will help you complete the requirement of the homework. The main objective is to read the content of the two .csv files and display information extracted from these files.
с
Country
USA
Massachusetts Institute of Technolog USA
USA
1 Institution name
2 Harvard University
3
4 Stanford University
5
University of Cambridge
6 University of Oxford
7 Princeton University
8 Columbia University
University of Chicago
9
10 University of Pennsylvania
11 Yale University
12 California Institute of Technology
United Kingd
United Kingd
USA
USA
USA
USA
USA
USA
USA
Japan
USA
USA
USA
USA
University of California/ Los Angeles USA
13 University of California/ Berkeley
University of Tokyo
14
15 Cornell University
16 University of Michigan/Ann Arbor
17 Johns Hopkins University
18 Northwestern University
19
20 University College London
21 Duke University
PSL University
22
France
23
University of Illinois at Urbanaâ€"Cha USA
24 University of Washington - Seattle USA
Canada
25 University of Toronto
26 University of Wisconsinâ€"Madison
27 New York University
28 McGill University
29 Kyoto University
30 ETH Zurich
31 Imperial College London
32 Seoul National University
33
34
35
36 Karolinska Institute
37 Sorbonne University
Paris-Saclay University
University of Texas at Austin
University of California/ San Diego
United Kingd
USA
USA
USA
Canada
Japan
Switzerland
United Kingd
South Korea
France
USA
USA
Sweden
France
Denmark
38 University of Copenhagen
39 University of California/ San Francisco USA
40
University of North Carolina at Chape USA
National Rank
D
1
2
3
1
5769SANI
2
4
8
10
2
11
12
13
14
15
3
16
1
17
18
1
19
20
2
1
1
4
1
2
21
22
1
3
1
23
24
Transcribed Image Text:с Country USA Massachusetts Institute of Technolog USA USA 1 Institution name 2 Harvard University 3 4 Stanford University 5 University of Cambridge 6 University of Oxford 7 Princeton University 8 Columbia University University of Chicago 9 10 University of Pennsylvania 11 Yale University 12 California Institute of Technology United Kingd United Kingd USA USA USA USA USA USA USA Japan USA USA USA USA University of California/ Los Angeles USA 13 University of California/ Berkeley University of Tokyo 14 15 Cornell University 16 University of Michigan/Ann Arbor 17 Johns Hopkins University 18 Northwestern University 19 20 University College London 21 Duke University PSL University 22 France 23 University of Illinois at Urbanaâ€"Cha USA 24 University of Washington - Seattle USA Canada 25 University of Toronto 26 University of Wisconsinâ€"Madison 27 New York University 28 McGill University 29 Kyoto University 30 ETH Zurich 31 Imperial College London 32 Seoul National University 33 34 35 36 Karolinska Institute 37 Sorbonne University Paris-Saclay University University of Texas at Austin University of California/ San Diego United Kingd USA USA USA Canada Japan Switzerland United Kingd South Korea France USA USA Sweden France Denmark 38 University of Copenhagen 39 University of California/ San Francisco USA 40 University of North Carolina at Chape USA National Rank D 1 2 3 1 5769SANI 2 4 8 10 2 11 12 13 14 15 3 16 1 17 18 1 19 20 2 1 1 4 1 2 21 22 1 3 1 23 24
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education