In html we have 2 types of table; Horizontal and Vertical. Is there a way to detect the type of the table in python?
Maybe this can be done using panda or BeautifulSoup?
<h2>Horizontal Headings:</h2>
<table style="width:100%">
<tr>
<th>Name</th>
<th>Telephone</th>
<th>Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
<h2>Vertical Headings:</h2>
<table style="width:100%">
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 77 854</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 77 855</td>
</tr>
</table>
My current function:
def is_vertical_table(table):
# Check if table is vertical and return true.
My initial thought where to check if all th tags are inside first tr tag but that doesn't seem as a perfect solution as some tags may be inside multiple tbody tags etc...