Using python 2.4 i have a .txt file sorted into 3 colums, 9 spaces between each column which is the reason for x.split – roughly 1000 lines ex:
$1$sda4356:[sgb1_diska5.ldlbat44.libabl]talild_0329_base.rpt talild_0329_base.rpt 00000000000000005062
I’m using the following code to sort by column 3 (which is file size)
fobj = open('data.txt')
data = [ x.split() for x in fobj ]
fobj.close()
from operator import itemgetter
data.sort(key=itemgetter(2), reverse=True)
I want to print the output of an entire column and if possible with Python 2.4 even name them. If i do something like data[1] it will just output line 2 how can i get this to show column 2 instead. If i can’t name it i see a few things with import csv but i can’t figure out the right command to use the data i’ve already sorted instead of calling up the .txt file again. Most are looking for file name as shown below
with open(filename, 'r') as f:
1 Answer