Currently I have the code below for a discord bot to display active fire calls in Toronto there are situations where alot of fire trucks are dispatched and when its scraped to a tabulate the dispatched units seem to overlap other columns and rows I want it be organized underneath each other in a column.
import discord
import requests
from bs4 import BeautifulSoup
from tabulate import tabulate
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
if __name__ == '__main__':
endpoint = "https://www.toronto.ca/data/fire/livecad.xml?i4sqso"
header = [
"Prime Street", "Cross Street", "Dispatch Time", "Incident Number",
"Incident Type", "Alarm Level", "Area", "Dispatched Units"
]
page = requests.get(endpoint).text
events = BeautifulSoup(page, "lxml").find_all("event")
event_table = []
for event in events:
row = event.getText(separator="|").split("|")
if len(row) == 7:
row.insert(1, "")
event_table.append(row)