Select date from calendar in selenium VBA - excel

I am using selenium in VBA and I have solved similar issue related to calendar but I am stuck on that calendar (I am sure it is related to javascript)
Here is the outer HTML of the calendar
<tr><td style="FONT-WEIGHT: bold; PADDING-BOTTOM: 5px; PADDING-TOP: 5px; BACKGROUND-COLOR: honeydew" valign="top" align="center" colspan="4"><table style="WIDTH: 632px" cellspacing="0" cellpadding="0"><tbody><tr><td style="WIDTH: 140px; PADDING-TOP: 10px" valign="top" align="center"><span id="ctl00_ContentPlaceHolder1_Label5" style="display:inline-block;width:125px;">Date</span> <span id="ctl00_ContentPlaceHolder1_Label14" style="color:Red;font-weight:bold;">*</span></td><td style="PADDING-RIGHT: 5px; PADDING-TOP: 10px" valign="middle" align="right"><table id="ctl00_ContentPlaceHolder1_Calendar_Receipt" cellspacing="0" cellpadding="2" title="Calendar" border="0" style="width:276px;height:166px;font-weight:bold;font-size:X-Small;font-family:Verdana;color:Black;border-width:1px;border-style:solid;border-color:White;background-color:White;border-collapse:collapse;">
<tbody><tr><td colspan="7" style="background-color:White;border-color:Black;border-width:4px;border-style:solid;"><table cellspacing="0" border="0" style="color:#333399;font-family:Verdana;font-size:12pt;font-weight:bold;width:100%;border-collapse:collapse;">
<tbody><tr><td valign="bottom" style="color:#333333;font-size:8pt;font-weight:bold;width:15%;">July</td><td align="center" style="width:70%;">August 2021</td><td align="right" valign="bottom" style="color:#333333;font-size:8pt;font-weight:bold;width:15%;">September</td></tr>
</tbody></table></td></tr><tr><th align="center" abbr="Sunday" scope="col" style="font-size:8pt;font-weight:bold;">Sun</th><th align="center" abbr="Monday" scope="col" style="font-size:8pt;font-weight:bold;">Mon</th><th align="center" abbr="Tuesday" scope="col" style="font-size:8pt;font-weight:bold;">Tue</th><th align="center" abbr="Wednesday" scope="col" style="font-size:8pt;font-weight:bold;">Wed</th><th align="center" abbr="Thursday" scope="col" style="font-size:8pt;font-weight:bold;">Thu</th><th align="center" abbr="Friday" scope="col" style="font-size:8pt;font-weight:bold;">Fri</th><th align="center" abbr="Saturday" scope="col" style="font-size:8pt;font-weight:bold;">Sat</th></tr><tr><td align="center" style="color:#999999;width:14%;">25</td><td align="center" style="color:#999999;width:14%;">26</td><td align="center" style="color:#999999;width:14%;">27</td><td align="center" style="color:#999999;width:14%;">28</td><td align="center" style="color:#999999;width:14%;">29</td><td align="center" style="color:#999999;width:14%;">30</td><td align="center" style="color:#999999;width:14%;">31</td></tr><tr><td align="center" style="width:14%;">1</td><td align="center" style="width:14%;">2</td><td align="center" style="width:14%;">3</td><td align="center" style="width:14%;">4</td><td align="center" style="width:14%;">5</td><td align="center" style="width:14%;">6</td><td align="center" style="width:14%;">7</td></tr><tr><td align="center" style="width:14%;">8</td><td align="center" style="width:14%;">9</td><td align="center" style="width:14%;">10</td><td align="center" style="width:14%;">11</td><td align="center" style="width:14%;">12</td><td align="center" style="width:14%;">13</td><td align="center" style="width:14%;">14</td></tr><tr><td align="center" style="width:14%;">15</td><td align="center" style="width:14%;">16</td><td align="center" style="color:White;background-color:Red;width:14%;">17</td><td align="center" style="width:14%;">18</td><td align="center" style="width:14%;">19</td><td align="center" style="width:14%;">20</td><td align="center" style="width:14%;">21</td></tr><tr><td align="center" style="width:14%;">22</td><td align="center" style="width:14%;">23</td><td align="center" style="width:14%;">24</td><td align="center" style="width:14%;">25</td><td align="center" style="width:14%;">26</td><td align="center" style="width:14%;">27</td><td align="center" style="width:14%;">28</td></tr><tr><td align="center" style="width:14%;">29</td><td align="center" style="width:14%;">30</td><td align="center" style="width:14%;">31</td><td align="center" style="color:#999999;width:14%;">1</td><td align="center" style="color:#999999;width:14%;">2</td><td align="center" style="color:#999999;width:14%;">3</td><td align="center" style="color:#999999;width:14%;">4</td></tr>
</tbody></table> </td></tr></tbody></table></td></tr>
Can you guide me how to deal with such calendar?
I noticed at these lines the following
1
The parameter which is '0' represents 01 January 2000 and this number changes to '1' on 02 Jaunuary 2000. Is it possible to go to specific date using such javascript directly?

Induce some wait and you can use either of the following Locator Strategies:
XPath:
//tr/td/a[#title='Go to the previous month' and text()='July']
Css:
tr>td>a[title='Go to the previous month']

Related

How to make an item always appear last on list (Netsuite Advanced PDF)

I am trying to make an item appear last on the list if it appears on an in the invoice (Advanced PDF,NetSuite).
I was thinking bout trying to sort by and adding some ZZZs to the item name, but thats because I dont really know much outside of basic HTML.
Any Help would be appreciated.
Below is the table code I am dealing with.
<table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
<tr>
<th align="center" colspan="3">${item.quantity#label}</th>
<th colspan="12">${item.item#label}</th>
<th colspan="3">${item.options#label}</th>
<th align="right" colspan="4">${item.rate#label}</th>
<th align="right" colspan="4">${item.amount#label}</th>
</tr>
</thead>
</#if><tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
I need the to be able to choose a specific itemname to always show at the bottom.
You can use the assign tag to hold the values for your bottom item.
<#assign bottomItemName = 'Bottom Item Name'>
<#assign bottomItem = {}>
<#list record.item as item>
<#if item_index==0>
<thead>
<tr>
<th align="center" colspan="3">${item.quantity#label}</th>
<th colspan="12">${item.item#label}</th>
<th colspan="3">${item.options#label}</th>
<th align="right" colspan="4">${item.rate#label}</th>
<th align="right" colspan="4">${item.amount#label}</th>
</tr>
</thead>
</#if>
<#if item.item == bottomItemName>
<#assign bottomItem = bottomItem + item>
<#else>
<tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#if>
</#list>
<#if bottomItem.item??>
<tr>
<td align="center" colspan="3" line-height="150%">${bottomItem.quantity}</td>
<td colspan="12"><span class="itemname">${bottomItem.item}</span><br />${bottomItem.description}</td>
<td colspan="3">${bottomItem.options}</td>
<td align="right" colspan="4">${bottomItem.rate}</td>
<td align="right" colspan="4">${bottomItem.amount}</td>
</tr>
</#if>
You could try looping 2x.
<table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
<tr>
<th align="center" colspan="3">${item.quantity#label}</th>
<th colspan="12">${item.item#label}</th>
<th colspan="3">${item.options#label}</th>
<th align="right" colspan="4">${item.rate#label}</th>
<th align="right" colspan="4">${item.amount#label}</th>
</tr>
</thead>
</#if><#if ${item.item}!="Your Item"><tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
<#list record.item as item><#if ${item.item}=="Your Item"><tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
I haven't tested the if statement, so good luck

How to you print one Result on the Advanced PDF Template from a Saved Search vs a list?

I have an Inbound Shipment saved search of items coming in listed by container. I have no problem printing the list of the items with quantities, description, etc. but when I add in the "vessel Number" or "shipment number" I don't need it to repeat on every line. I would prefer to show the information that I would normally "group" at the top of the PDF vs. on each line.
I should note that when I print the saved search, I would have already filtered the search down to one container, meaning only one "shipment number" and one "vessel number".
<table align="center" border=".5" cellpadding=".5" cellspacing=".5" class="NATIVE-TABLE" style="width:100%;"><#list results as result><#if result_index == 0>
<thead>
<tr>
<th align="center" scope="col" style="width: 107px;">
<div><big>Shipment #</big></div>
</th>
<th align="center" scope="col" style="width: 103px;">
<div><big>Status</big></div>
</th>
<th align="center" scope="col" style="width: 156px;">
<div><big>Destination</big></div>
</th>
<th align="center" scope="col" style="width: 150px;">
<div><big>Actual Ship Date</big></div>
</th>
<th align="center" scope="col" style="width: 154px;">
<div><big>Expected Delivery Date</big></div>
</th>
<th align="center" scope="col">
<div><big>Carrier</big></div>
</th>
<th align="center" scope="col">
<div><big>Vessel #</big></div>
</th>
</tr>
</thead>
</#if><tr>
<td align="center" style="width: 107px;">${result.shipmentnumber}</td>
<td align="center" style="width: 103px;">${result.status}</td>
<td align="center" style="width: 156px;">${result.custrecord142}</td>
<td align="center" style="width: 150px;">${result.actualshippingdate}</td>
<td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
<td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
<td align="center" style="width: 154px;">${result.vesselnumber}</td>
</tr>
</#list></table>
First: please post your code so we can see where you're up to and respond accordingly - it helps us to help you!
Second: The general pattern would be that you simply use values from the first result to make up your header, and then iterate through all results to give your lines. It would look something like:
<#list results as result>
<#if result_index == 0>
*header information goes here*
</#if>
*line information goes here*
</#list>
Edited to add code
<table align="center" border=".5" cellpadding=".5" cellspacing=".5" class="NATIVE-TABLE" style="width:100%;"><#list results as result><#if result_index == 0>
<thead>
<tr>
<th align="center" scope="col" style="width: 107px;">
<div><big>Shipment #</big></div>
</th>
<th align="center" scope="col" style="width: 103px;">
<div><big>Status</big></div>
</th>
<th align="center" scope="col" style="width: 156px;">
<div><big>Destination</big></div>
</th>
<th align="center" scope="col" style="width: 150px;">
<div><big>Actual Ship Date</big></div>
</th>
<th align="center" scope="col" style="width: 154px;">
<div><big>Expected Delivery Date</big></div>
</th>
<th align="center" scope="col">
<div><big>Carrier</big></div>
</th>
<th align="center" scope="col">
<div><big>Vessel #</big></div>
</th>
</tr>
</thead>
<tr>
<td align="center" style="width: 107px;">${result.shipmentnumber}</td>
<td align="center" style="width: 103px;">${result.status}</td>
<td align="center" style="width: 156px;">${result.custrecord142}</td>
<td align="center" style="width: 150px;">${result.actualshippingdate}</td>
<td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
<td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
<td align="center" style="width: 154px;">${result.vesselnumber}</td>
</tr>
</#if>
<tr>
<td align="center" style="width: 107px;"></td>
<td align="center" style="width: 103px;">${result.status}</td>
<td align="center" style="width: 156px;">${result.custrecord142}</td>
<td align="center" style="width: 150px;">${result.actualshippingdate}</td>
<td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
<td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
<td align="center" style="width: 154px;"></td>
</tr>
</#list>
</table>

Is that some tips to write dustjs template for faster render? node.js

I use dustjs to render my mail content and I found that it's slow when render some bigger templates. Is any tips when write dustjs template to increase the render speed, or some good practice?
details:
my template consists of several components (more than 5), each component if different from others, there is one example of the component as follow:
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" width="650">
<tr>
<td align="center">
<table width="590" border="0" cellspacing="0" cellpadding="0">
{#eq key=haveBanner value=1}
<tr>
<td height="105" align="center" valign="middle">
<img src="{bannerUrl|pictureUrl}" width="590" border="0">
</td>
</tr>
{:else}
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="590" height="75" style="border-top:solid 3px #343434">
<tr>
<td width="130" align="left" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" height="55">
<img src="{sellerLogo|pictureUrl}" width="110" height="55">
</td>
</tr>
</table>
</td>
<td width="460" align="left">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><font style="font-family:arial;font-size:16px;color:#292929">{compName}</strong></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
{/eq}
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #dbdbdb" width="594">
<tr>
<td width="149" valign="top" style="border-right:solid 1px #dbdbdb">
<table width="146" cellspacing="0" cellpadding="0">
<tr>
{#eq key=selectedProductFlag value=1}
<td height="80" style="padding:20px 20px"><font style="font-family:arial;font-size:18px;color:#333333"><b>Promotion Products</b></font></td>
{:else}
<td height="80" style="padding:20px 20px"><font style="font-family:arial;font-size:18px;color:#333333"><b>Promotion Products</b></font></td>
{/eq}
</tr>
<tr>
<td align="center" height="26" valign="top">
<table width="119" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border-top:solid 1px #e5e5e5"><img src="http://newimg.globalmarket.com/PA/edm/images/spacer.gif" height="1" width="1"></td>
</tr>
</table>
</td>
</tr>
{#finalProdGroupList}
<tr>
<td height="35" valign="top">
<table width="146" cellspacing="0" cellpadding="0">
<tr>
<td style="padding-left:25px"><font style="font-family:arial;font-size:12px;color:#484848">{prodGroupName}</font></td>
</tr>
</table>
</td>
</tr>
{/finalProdGroupList}
</table>
</td>
<td width="443" valign="top">
<table width="442" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="442" border="0" cellspacing="0" cellpadding="0" height="255">
<tr>
{#secondaryProducts}
{#productList spIdx=$idx}
{#eq key=$idx value=2}
<td align="center" valign="top" width="147">
{:else}
<td align="center" valign="top" style="border-right:solid 1px #dbdbdb" width="147">
{/eq}
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="146" align="center">
<img src="{photoUrl|pictureUrl}" border="0" width="126" height="126" alt="{fullProdName}">
</td>
</tr>
<tr>
<td align="center">
<table width="126" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="126">
<tr>
<td align="left" height="33" valign="top" style="line-height:15px">
<font style="font-family:Arial;font-size:12px;color:#333333">{productName}</font>
</td>
</tr>
<tr>
<td align="left" height="20" valign="middle"><font style="font-family:Arial;font-size:12px;color:#999999">{certification}</font></td>
</tr>
<tr>
{#eq key=payForInqFlag value=1}
<td align="left" height="35" valign="middle"><img src="http://newimg.globalmarket.com/PA/edm/images/getprice2.png" width="128" height="25"></td>
{:else}
<td align="left" height="35" valign="middle"><img src="http://newimg.globalmarket.com/PA/edm/images/getprice2.png" width="128" height="25"></td>
{/eq}
</tr>
<tr>
<td height="7"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
{/productList}
{/secondaryProducts}
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
Your problem is very likely the large amount of Dust filters you are using.
Example:
&{trackCodeData|gaTrackCode|dbTrackCode|entityId|entityType|edmpid|recId|userId|token|final}
Some of these filters are even being run in a loop. It looks like you are running well over 100 filters per render of this template. Filters are executed synchronously and serially, so Dust can't continue to render the template until the filter is done.
Without knowing what these filters do, it's hard to make specific recommendations about the filters themselves. However, you seem to use the same filters multiple times to output the same data. If possible, you should pregenerate this data and add it into the context instead of dynamically generating it.
You can gain a few more cycles by turning on whitespace compression, if you have it turned off:
dust.config.whitespace = false;
But Dust intrinsically is very fast. Without your filters, your template renders in around 3ms for me.

cellSpace not working in DreamWeaver CS6

I've pasted table code to new div in gridContainer div (using the Fluid Grid Layout option)
Everything seems fine but the cell spacing defined, when I try to change the spacing nothing happens, it keeps it on 0.
Following is the table markup:
<table align="center" cellpadding="0" cellspacing="15">
<col span="7" width="160px" />
<row span="7" width="160px" />
<!---Row 1--->
<tr align="center" height="160px">
<td colspan="2" >
<img src="images/buttons/Optimus.png" />
</td>
<td colspan="2" >
<img src="images/buttons/MapleSim.png">
</td>
<td colspan="2" >
</td>
<td colspan="1" bgcolor="#40b040">
<img src="images/buttons/about_us.png">
</td>
</tr>
<!---Row 2--->
<tr align="center" height="160px">
<td colspan="2" bgcolor="#40b040">
<img src="images/buttons/QFD.white.png">
</td>
<td colspan="1" bgcolor="#cc00cc">
<img src="images/buttons/learning_maple.png">
</td>
<td colspan="3" rowspan="2"
align="left" valign="top" bgcolor="#aaaaff">
<img src="images/buttons/news.png">
News will be shown here
</td>
<td colspan="1" bgcolor="#ff0000">
<img src="images/buttons/services.png">
</td>
</tr>
<!---Row 3--->
<tr align="center" height="160px">
<td colspan="1" bgcolor="#6766cc">
<img src="images/buttons/events.png">
</td>
<td colspan="1" bgcolor="#cccc00">
<img src="images/buttons/forum.png">
</td>
<td colspan="1" bgcolor="#4040ff">
<img src="images/buttons/links.png">
</td>
<td colspan="1" bgcolor="#ffbf00">
<img src="images/buttons/shopping_cart.png">
</td>
</tr>
<!---Row 4--->
<tr align="center" height="160px">
<td colspan="2" bgcolor="#ff0000">
<img src="images/buttons/commercial_users.png">
</td>
<td colspan="1" bgcolor="#ffbf00">
<img src="images/buttons/student_special.png">
</td>
<td colspan="1" bgcolor="#40b000">
<img src="images/buttons/student_special.png">
</td>
<td colspan="1" bgcolor="#ff00cc">
<img src="images/buttons/instruction.png">
</td>
<td colspan="1" bgcolor="#cc00cc">
<img src="images/buttons/learning_maple.png">
</td>
<td colspan="1" bgcolor="#4040ff">
<img src="images/buttons/download.png">
</td>
</tr>
</table>
You can see in this line <table align="center" cellpadding="0" cellspacing="15"> the spacing is 15, but when checking on any browser it shows as it set to 0
Any ideas how to solve it?
Thanks in advance,
Shahar
Ok, I guess I was too hasty.
It appears that the table used two definitions from boilerplate.css
table {
/* [disabled]border-collapse: collapse; */
/* [disabled]border-spacing: 0; */
}
As you can see, simply disabling them resolved the issue.
If there is any other option to override without disabling (maybe usage of !important) I'll be glad to know about it.

concat multiple df made from pd.read_html

my title does not make any sense so i am going to give brief about situation
i am scraping data from site which basically table but in this case every row is a table element and also every odd table element is not useful so i am eliminating
so what i want is concatenation of every individual dataframe made up of every even table element using read_html()
below is my code
import pandas as pd
all_table = ["""<table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr height="10px">
<td align="right" colspan="9">
<font color="#D5D5D5">.</font>
</td>
</tr>
<tr height="30px" valign="middle" width="100%">
<td class="size-12" colspan="8" width="100%">
<strong>Shipment Status</strong>
</td>
</tr>
<tr valign="bottom" width="100%">
<td align="center" class="size-10" width="10%">
<strong>Station</strong>
</td>
<td align="center" class="size-10" width="10%">
<strong>Flight No.</strong>
</td>
<td align="center" class="size-10" width="25%">
<strong>Status</strong>
</td>
<td align="center" class="size-10" width="15%">
<strong>Date</strong>
</td>
<td align="center" class="size-10" width="9%">
<strong>Time</strong>
</td>
<td align="center" class="size-10" width="8%">
<strong>Pcs</strong>
</td>
<td align="center" class="size-10" width="8%">
<strong>Wgt</strong>
</td>
<td align="center" class="size-10" width="15%">
<strong>ULD - Battery - Temp</strong>
</td>
</tr>
<tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">KIX</td>
<td align="center" class="size-10" width="10%">
<center>-</center>
</td>
<td align="center" class="size-10" width="25%">Shipment Received</td>
<td align="center" class="size-10" width="15%">11 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 22:45</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#FFFFFF" class="result-row">
<td align="center" class="size-10" width="10%">KIX</td>
<td align="center" class="size-10" width="10%">
<center>-</center>
</td>
<td align="center" class="size-10" width="25%">Freight On Hand</td>
<td align="center" class="size-10" width="15%">11 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 22:45</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">KIX</td>
<td align="center" class="size-10" width="10%">SQ0621</td>
<td align="center" class="size-10" width="25%">Flight Departed</td>
<td align="center" class="size-10" width="15%">13 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 17:18</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#FFFFFF" class="result-row">
<td align="center" class="size-10" width="10%">SIN</td>
<td align="center" class="size-10" width="10%">SQ0621</td>
<td align="center" class="size-10" width="25%">Flight Arrived</td>
<td align="center" class="size-10" width="15%">13 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 23:02</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">SIN</td>
<td align="center" class="size-10" width="10%">SQ0621</td>
<td align="center" class="size-10" width="25%">Flight Arrived</td>
<td align="center" class="size-10" width="15%">13 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 23:02</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#FFFFFF" class="result-row">
<td align="center" class="size-10" width="10%">SIN</td>
<td align="center" class="size-10" width="10%">SQ0621</td>
<td align="center" class="size-10" width="25%">Shipment Checked Into Warehouse</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 02:57</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">SIN</td>
<td align="center" class="size-10" width="10%">SQ0422</td>
<td align="center" class="size-10" width="25%">Flight Departed</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 07:39</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#FFFFFF" class="result-row">
<td align="center" class="size-10" width="10%">BOM</td>
<td align="center" class="size-10" width="10%">SQ0422</td>
<td align="center" class="size-10" width="25%">Flight Arrived</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 10:12</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">BOM</td>
<td align="center" class="size-10" width="10%">SQ0422</td>
<td align="center" class="size-10" width="25%">Flight Arrived</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 10:30</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#FFFFFF" class="result-row">
<td align="center" class="size-10" width="10%">BOM</td>
<td align="center" class="size-10" width="10%">SQ0422</td>
<td align="center" class="size-10" width="25%">Shipment Checked Into Warehouse</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 14:10</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">BOM</td>
<td align="center" class="size-10" width="10%">
<center>-</center>
</td>
<td align="center" class="size-10" width="25%">Shipment Ready for Pick-up</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 14:21</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#FFFFFF" class="result-row">
<td align="center" class="size-10" width="10%">BOM</td>
<td align="center" class="size-10" width="10%">
<center>-</center>
</td>
<td align="center" class="size-10" width="25%">Document Delivered</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 17:15</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
</table>, <table cellpadding="0" cellspacing="0" cols="8" width="100%">
<tbody><tr bgcolor="#F0F0F0" class="result-row">
<td align="center" class="size-10" width="10%">BOM</td>
<td align="center" class="size-10" width="10%">
<center>-</center>
</td>
<td align="center" class="size-10" width="25%">Shipment Delivered</td>
<td align="center" class="size-10" width="15%">14 Oct 2019</td>
<td align="center" class="size-10" width="9%"> 17:15</td>
<td align="center" class="size-10" width="8%">34</td>
<td align="center" class="size-10" width="8%">411.3</td>
<td align="center" class="size-10" width="15%"></td>
</tr>
</tbody></table>"""]
final_delivary = pd.DataFrame()
a = 0
for i in range(len(all_table)):
print("-"*150)
if a % 2 == 0:
print(a)
# print(all_table[a])
tmp_table = all_table[a]
tmp_df = pd.read_html(str(tmp_table))
print("tmp_df = \n", tmp_df)
print("type of tmp_df = ", type(tmp_df))
print("#"*75)
tmp_df2 = pd.DataFrame(tmp_df[0])
print("tmp_df2 = \n", tmp_df2)
print("type of tmp_df2 = ", type(tmp_df2))
print("#"*75)
print("final_delivary = \n", final_delivary)
print("type of final_delivary = ", type(final_delivary))
pd.concat([final_delivary, tmp_df2], axis=0)
else:
print("nope")
a+=1
print("final_delivary = ", final_delivary)
so i am facing problem while concatenating individual dataframe to main dataframe and result am getting is empty dataframe so please help me with that
Try this
from bs4 import BeautifulSoup as bs
import pandas as pd
all_table = '''
html content
'''
finalDf = pd.DataFrame()
soup = bs(all_table)
tables = soup.findAll("table")
for i,table in enumerate(tables):
if i%2==0:
df = pd.read_html(str(table))
finalDf = pd.concat([finalDf,df[0]])

Resources