I have a file (see status variable in the code below) that I want to convert into a flowchart (attached). My python script converts "status" into a dictionary. How do I convert that dictionary into a flowchart or a graphic? my code:
status = """
Object car {
Name honda;
From Richland;
To Seattle;
Distance 160;
Configuration road_travel;
}
Object bus {
Name greyhound;
From pasco;
To richland;
Distance 15;
Configuration road_travel;
}
Object aeroplane {
Name united;
From miami_airport;
To pasco;
Distance 1000;
Configuration air_travel;
}
Object train {
Name gas_train;
From beach;
To miami_airport;
Distance 30;
Configuration train_travel;
}
"""
sale_number = ''
sales = collections.defaultdict(list)
for line in status.split('\n'):
line = line.strip()
if line.startswith("set"):
continue
elif (line.startswith("Object") or line.startswith("object")):
sale_number = line.split(' ')[1].strip()
elif not line or line.isspace() :
continue
else:
# you can also use a regular expression here
sales[sale_number].append(line.split())
for sale in sales:
print sale+str(dict(sales[sale][:-1]))
and this generates:
car{'To': 'Seattle;', 'Configuration': 'road_travel;', 'From': 'Richland;', 'Name': 'honda;', 'Distance': '160;'}
train{'To': 'miami_airport;', 'Configuration': 'train_travel;', 'From': 'beach;', 'Name': 'gas_train;', 'Distance': '30;'}
aeroplane{'To': 'pasco;', 'Configuration': 'air_travel;', 'From': 'miami_airport;', 'Name': 'united;', 'Distance': '1000;'}
bus{'To': 'richland;', 'Configuration': 'road_travel;', 'From': 'pasco;', 'Name': 'greyhound;', 'Distance': '15;'}
and I want to convert the above python output into a picture that looks something like below. I don't want to do it manually using Giffy or MS-Visio because my practical cases have about 1000 objects (this example has 4 objects in "status")