Hello,

I'm a newby to Python and I want to write a function which imports a CSV file and
returns a dictionary for the index of each subcategory in a column like this:
hockey: 3, Tennis: 54, volleyball: 59.

Any advise on how to adjust my code?
Thanks!

import csv

with open('pythonfile.csv', newline='') as csvfile:
test = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in pythonfile:
    print(', '.join(row))

Can you please include the CSV format as a post attachment so we can understand the format of the file? Thanks!

commented: shape guess game python GUI tkinter +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.