+ 2

Python array and csv file

Hi guys if I have a csv file consist of : name,age how do i make a list/arrays of age only in python ? e.g of csv file Michael,12 James,10 Ryan,21 Thanks before!

23rd Nov 2018, 12:33 AM
Sherwin Chia
Sherwin Chia - avatar
2 odpowiedzi
+ 2
You can import the csv module, See https://docs.python.org/3/library/csv.html
23rd Nov 2018, 4:36 AM
David Ashton
David Ashton - avatar
+ 1
You can use import numpy my_data = numpy.genfromtxt('my_file.csv', delimiter=',')
1st Jan 2019, 2:31 AM
Laura Madrigal
Laura Madrigal - avatar