1.

Write a python program to read a csv file and store a column value in a list for sorting?

Answer»

python file

F=open(inFile;’r’)

# reading the File with the help of csv.reader( ) reader = csv.reader(F)

# skipping the first row(heading) next( reader)

# declaring a list array Value = [ ]

a= int(input (“Enter the column number 1 to 3:-“))

# sorting a particular column-cost for row in reader: 

array Value. append(row[a])

array Value.sorif) for row in array Value: print (row) 

F.close( )

OUTPUT

Enter the column number 1 to 3:-

2

50

12

10



Discussion

No Comment Found