How can i store data of a specific column in a csv file for example Name, in a list using python? When i try to output It output repeatedly enter image description here
Please help
How can i store data of a specific column in a csv file for example Name, in a list using python? When i try to output It output repeatedly enter image description here
Please help
One possibility would be to use a list comprehension.
import csv
with open("names.csv", "r") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",")
# List comprehension
csv_list = [line[0] for line in csv_reader]
The "0" in line[0] can be changed to be whichever column is desired.