Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. Traceback (most recent call last):
  2. File "test.py", line 20, in <module>
  3. mod_f.write(','.join(line) + 'n')
  4. TypeError: sequence item 3: expected string, float found
  5.  
  6. mod_f = open("mod_c_vol_size.txt", 'w')
  7. mod_f.write("Vserver,Volume,Aggregate,Total,Avail,Node,SaveA,SaveD,SaveC,Snap,Tusedn")
  8. unit = ['TB', 'GB', 'MB', 'KB', 'B']
  9. with open("find_c_vol_modify.txt", "r") as f:
  10. next(f)
  11. for line in f:
  12. if len(line.strip()) != 0:
  13. line = line.split(',')
  14. out = []
  15. for l in line[3:5] + line[6:11]:
  16. l = l.replace('n','')
  17. try:
  18. ind = [unit[i] in l for i in range(5)].index(True)
  19. except ValueError:
  20. print('please check script')
  21.  
  22. val = str(l.split(unit[ind])[0])
  23. out.append(float(val)/1024**ind)
  24. line = line[0:3] + out[:-5] + line[5:6] + out[2:]
  25. print (line)
  26. mod_f.write(','.join(line) + 'n')
  27. mod_f.close()
  28.  
  29. Vserver,Volume,Aggregate,Total,Avail,Node,SaveA,SaveD,SaveC,Snap,Tused
  30. XXXX,YYYY,Node1_aggr1,1TB,1023GB,FAS8040-ZZZZ,0B,0B,0B,0B,177.7MB
  31. XXXX,ZZZZ,Node1_aggr1,3TB,3.00TB,FAS8040-ZZZZ,0B,0B,0B,0B,1.60GB
  32. XXXX,CCCC,Node1_aggr1,1TB,907.9GB,FAS8040-ZZZZ,0B,0B,0B,0B,116.1GB
  33. XXXX,VVVV,Node1_aggr1,200GB,200.0GB,FAS8040-ZZZZ,0B,0B,0B,0B,6.25MB
  34.  
  35. ['XXXX', 'YYYY', 'Node1_aggr1', 1.0, 0.9990234375, 'FAS8040-ZZZZ', 0.0, 0.0, 0.0, 0.0, 0.00016946792602539061]
  36. ['XXXX', 'ZZZZ', 'Node1_aggr1', 3.0, 3.0, 'FAS8040-ZZZZ', 0.0, 0.0, 0.0, 0.0, 0.0015625]
  37. ['XXXX', 'CCCC', 'Node1_aggr1', 1.0, 0.88662109375, 'FAS8040-ZZZZ', 0.0, 0.0, 0.0, 0.0, 0.11337890625]
  38. ['XXXX', 'VVVV', 'Node1_aggr1', 0.1953125, 0.1953125, 'FAS8040-ZZZZ', 0.0, 0.0, 0.0, 0.0, 5.9604644775390625e-06]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement