Successfully appending %kbavail val and printing key,val for each cell

in a given row.
	modified:   sadfadd
	outfile.csv
master
m00t 5 years ago
parent 50379a4646
commit be3d5a68c8
  1. 6
      sadfadd

@ -24,12 +24,14 @@ def main(argv):
with open(tempfile, newline='') as csvfile:
csvreader = csv.DictReader(csvfile, delimiter=';')
for row in csvreader:
rowkeys = row.keys()
rowkeys = iter(row.keys())
kbtotal = int(row.get('kbmemused')) + int(row.get('kbmemfree'))
kbavail = int(row.get('kbavail'))
percavail = (kbavail/kbtotal)
fmtpavail = str('{:.1%}'.format(percavail))
row.update({'%kbavail':fmtpavail})
print(row['# hostname'],row['timestamp'],row['%kbavail'])
for key,val in zip(row.keys(),row.values()):
print(str(key))
print(str(val))
if __name__ == "__main__":
main(sys.argv[1:])

Loading…
Cancel
Save