Advertisement
Guest User

dave 2

a guest
Nov 22nd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. ileList = glob.glob('/home/ec2-user/dev/two_angle/clutter_100k/*')
  2. progress = 0
  3. simulation_results  = {}
  4.  
  5.  
  6. for f in fileList:
  7.   if not progress % 100:
  8.     print "Finished loading %d keys" % progress
  9.   progress += 1
  10.   try:
  11.     with open(f) as fid:
  12.       result = json.load(fid)
  13.   except IOError:
  14.     print "bad file"
  15.     continue
  16.  
  17.   try:
  18.     bag_id = result['input']['experimental']['bag_id']
  19.     if not simulation_results.has_key(bag_id):
  20.       simulation_results[bag_id] = []
  21.  
  22.     simulation_results[bag_id].append(result)
  23.   except KeyError:
  24.     print "bad file"
  25.     continue
  26.  
  27. print "data org for clutter"
  28. outputs = []
  29. progress = 0
  30. for bag_id in simulation_results:
  31.   if not progress % 100:
  32.     print "Finished writing %d simulations" % progress
  33.   progress += 1
  34.   tmp_out = simulation_results[bag_id]['output']
  35.   tmp1 = re.sub(' \n',' ', tmp_out)
  36.   outputs.append(tmp1)
  37.  
  38. fileName = '/home/ec2-user/clutterData/clutter_100k_2angle.txt'
  39. threat_file = open(fileName, 'w+')
  40. threat_file.write("".join(str(j) for j in outputs) )
  41. threat_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement