python - How to Print a Specific Value in an Array from a CSV File -
i imported csv file , made data array. wondering, can i'm able print specific value in array? instance if wanted value in 2nd row, 2nd column. how go adding 2 values together? thanks.
import csv import numpy np f = open("test.csv") csv_f = csv.reader(f) row in csv_f: print np.array(row) f.close()
to specific values within array/file, , add together:
import csv f = open("test.csv") csv_f = list(csv.reader(f)) #returns value in second row, second column of file print csv_f[1][1] #returns sum of 2 specific values (in example, value of second row, second column , value of first row, first column sum = int(csv_f[1][1]) + int(csv_f[0][0]) print sum
Comments
Post a Comment