48 if not os.path.isfile(filename):
49 raise RdtError(filename+
' is not a valid rdt file.')
51 with open(filename)
as f:
53 hlist=f.readline().split(
',')
61 vlist = line.split(
',')
63 if first.strip() !=
"#":
66 d[hi][1].append(float(v.strip()))
71 for k, v
in rdt_d.iteritems():
78 print "\nUsage: rdt.py -i input.rdt [-a] [-f field] [-h]\n" 80 print "\t-i input.rdt: input rdt file." 81 print "\t-f field: print selected column." 82 print "\t-a : print all columns." 83 print "\t-h : this help :-)." 85 print "\tReads the contents of a RDT file and prints its contents." 89 sys.stderr.write(
'ERROR: '+message+
'\n')
93 if __name__ ==
"__main__":
98 opts, extra_args = getopt.getopt(sys.argv[1:],
'i:f:ah')
100 if f ==
'-i': inputfn=v
101 elif f ==
'-f': field=v
102 elif f ==
'-a': printa=
True 103 elif f ==
'-h':
usage()
106 error(
"An input file name must be provided.", 1)
114 print "-- All values ---------" 116 print "-----------------------" 120 print field,
" : ", values
def error(message, status)
def get_column_values(rdt_d, field)