import json
import os

directory = '/home/david/git/cse_6242_PCA_Vis/dimension_reduction_code'

json_file = directory + '/Data/Json_Files/12_samples_json_' + \
    'truncated_to_strain_375.JSON'

reduced_data = []
with open(json_file, 'rb') as f:
    for line in f:
        reduced_data.append(json.loads(line))

reduced_data_names = sorted(reduced_data[0].keys())

directory_property = directory + '/Data/Load_Strain_and_Crystallinity'

file_names = sorted(os.listdir(directory_property))
dict_list = []
name_index = 0
for file_name in file_names:
    f = open(os.path.join(directory_property, file_name), 'rb')
    data = f.readlines()
    data_cleaned = [i[:-1] for i in data]
    split_data = [i.split('\t') for i in data_cleaned]
    converted_data = map(list, zip(*split_data))
    key = reduced_data_names[name_index]
    dict_list.append({'sample': key})
    dict_list.append({'points': reduced_data[0][key]})
    name_index += 1
    [dict_list.append({prop[:1][0]: prop[1:]}) for prop in converted_data]

with open(os.path.join(directory, 'Vis_data.json'), 'w') as json_file:
            json.dump(dict_list, json_file)

@@ -88,17 +88,16 @@
 n_code'%0A
-%0A
 json_fil
@@ -118,24 +118,8 @@
 + '/
-Data/Json_Files/
 12_s
@@ -134,19 +134,8 @@
 son_
-' + %5C%0A    '
 trun
@@ -330,17 +330,16 @@
 keys())%0A
-%0A
 director
@@ -402,16 +402,171 @@
 inity'%0A%0A
+%0Adef _get_pic_suffix(sample_name, time):%0A    zeros = '_0000'%0A    time_str = str(time)%0A    return sample_name + zeros%5B:-len(time_str)%5D + time_str + '.png'%0A%0A
 file_nam
@@ -862,162 +862,372 @@
     
-converted_data = map(list, zip(*split_data))%0A    key = reduced_data_names%5Bname_index%5D%0A    dict_list.append(%7B'sample': key%7D
+pt_index = 0%0A    for pt in split_data%5B1:%5D:%0A        pt_dict = %7B%7D%0A        sample_name = reduced_data_names%5Bname_index%5D%0A        pt_dict%5B'sample'%5D = sample_name%0A        pt_dict%5B'time'%5D = pt_index%0A        pic_name = _get_pic_suffix(sample_name, pt_index
 )%0A    
+ 
-dict_list.append(%7B
+   pt_dict%5B'pic'%5D = pic_name%0A        points = reduced_data%5B0%5D%5Bsample_name%5D%5Bpt_index%5D%0A        pt_dict%5B
 'points'
 : re
@@ -1222,17 +1222,19 @@
 'points'
-:
+%5D =
  reduced
@@ -1246,109 +1246,358 @@
 %5B0%5D%5B
-key%5D%7D)%0A    name_index += 1%0A
+sample_name%5D%5Bpt_index%5D%0A    
     
-%5B
+pt_
 dict
-_list.append(%7Bprop%5B:1%5D%5B0%5D: prop%5B1:%5D%7D) for prop in converted_data%5D
+%5B'percent_crystallinity'%5D = float(pt%5B0%5D)%0A        pt_dict%5B'percent_orthorhombic'%5D = float(pt%5B1%5D)%0A        pt_dict%5B'percent_monoclinic'%5D = float(pt%5B2%5D)%0A        pt_dict%5B'Load_in_Kgs'%5D = float(pt%5B3%5D)%0A        pt_dict%5B'strain'%5D = float(pt%5B4%5D)%0A        dict_list.append(pt_dict)%0A        pt_index += 1%0A    name_index += 1%0A
 %0A%0Awi
@@ -1665,24 +1665,16 @@
 n_file:%0A
-        
     json

Update make_json