print("zaciname")                                                                                                                                                                                                                         
import re, json

search_str = '|'
final = []
counter = 1
with open("/home/unipi/flowserver/databases/nodes.table", 'r') as file:
# with open("/home/rasta5man/dev/oms/flowserver/databases/nodes.table", 'r') as file:
    # Read each line in the file
    for line in file:
        # Print each line
        line = line.strip()
        print(line)
        if counter != 1:
            i = [m.start() for m in re.finditer(re.escape(search_str), line)]
            node =  line[ i[0] + 1 : i[1] ]
            tbname =  line[ i[3] + 1 : i[4] ]
            final.append({node:tbname})
        counter += 1
print(json.dumps(final))
f = open("/home/unipi/flowserver/databases/nodes_original/nodes_original.table", "w")
f.write(json.dumps(final))
f.close()


#
# # ``d`` has to be replaced with a different character
# old_character = "'"
#
# # ``t`` will replace ``d`
# new_character = '"'
# resultant_string = 0;
# with open("/home/unipi/flowserver/databases/nodes_original/nodes_original.table", 'r') as file:
#     for line in file:
#         resultant_string = re.sub("'", '"', line)
#
#         resultant_string = re.sub(" ", "", resultant_string)
# print(resultant_string)
#
# f = open("/home/unipi/flowserver/databases/nodes_original/nodes_original.table", "w")
# f.write(str(resultant_string))
# f.close()
#
