def test_gettables(): """py.test for gettables""" thedata = ( ([('Site and Source Energy', [['a', '2'], ['3', '4']]), ('Site to Source Energy Conversion Factors', [['b', '6'], ['7', '8']]), ('Custom Monthly Report', [['c', '16'], ['17', '18']]), ('Custom Monthly Report', [['d', '26'], ['27', '28']])], False), # titlerows, tofloat ([('Site and Source Energy', [['a', 2], [3, 4]]), ('Site to Source Energy Conversion Factors', [['b', 6], [7, 8]]), ('Custom Monthly Report', [['c', 16], [17, 18]]), ('Custom Monthly Report', [['d', 26], [27, 28]])], True), # titlerows, tofloat ) for titlerows, tofloat in thedata: # print titlerows result = readhtml.titletable(SAMPLE_HTML, tofloat=tofloat) for (title1, rows1), (title2, rows2) in zip(result, titlerows): # print title1, title2 assert title1 == title2 # print rows1, rows2 assert rows1 == rows2 assert result == titlerows
def test_gettables(): """py.test for gettables""" thedata = (([('Site and Source Energy', [['a', '2'], ['3', '4']]), ('Site to Source Energy Conversion Factors', [['b', '6'], ['7', '8']]), ('Custom Monthly Report', [['c', '16'], ['17', '18']]), ('Custom Monthly Report', [['d', '26'], ['27', '28']])], False), # titlerows, tofloat ([('Site and Source Energy', [['a', 2], [3, 4]]), ('Site to Source Energy Conversion Factors', [['b', 6], [7, 8]]), ('Custom Monthly Report', [['c', 16], [17, 18]]), ('Custom Monthly Report', [['d', 26], [27, 28]])], True), # titlerows, tofloat ) for titlerows, tofloat in thedata: # print titlerows result = readhtml.titletable(SAMPLE_HTML, tofloat=tofloat) for (title1, rows1), (title2, rows2) in zip(result, titlerows): # print title1, title2 assert title1 == title2 # print rows1, rows2 assert rows1 == rows2 assert result == titlerows
def test_gettables(): """py.test for gettables""" thedata = (("""<b>this is the title</b> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table> """, [('this is the title', [['1', '2'], ['3', '4']])]), # html_doc, titlerows ("""<b>this is the title 1</b> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table> <b>this is the title 2</b> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>11</td> <td>22</td> </tr> <tr> <td>33</td> <td>44</td> </tr> </table> """, [('this is the title 1', [['1', '2'], ['3', '4']]), ('this is the title 2', [['11', '22'], ['33', '44']])]), # html_doc, titlerows ("""<b>this is the title 1</b> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table> <b>this is the title 2</b> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>11</td> <td>22</td> </tr> <tr> <td>33</td> <td>44</td> </tr> </table> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>111</td> <td>222</td> </tr> <tr> <td>333</td> <td>444</td> </tr> </table> <b>this is the title 1</b> <table border="1" cellspacing="0" cellpadding="4"> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table> """, [('this is the title 1', [['1', '2'], ['3', '4']]), ('this is the title 2', [['11', '22'], ['33', '44']]), ('this is the title 2', [['111', '222'], ['333', '444']]), ('this is the title 1', [['1', '2'], ['3', '4']])]), # html_doc, titlerows ) for html_doc, titlerows in thedata: result = readhtml.titletable(html_doc) assert result == titlerows
# # The number you want is in the third row, second column and it's value is "47694.47" # # Let us use eppy to extract this number # <codecell> from eppy import readhtml # the eppy module with functions to read the html fname = ( "../eppy/resources/outputfiles/V_7_2/5ZoneCAVtoVAVWarmestTempFlowTable_ABUPS.html" ) # the html file you want to read filehandle = open(fname, "r").read() # get a file handle to the html file htables = readhtml.titletable(filehandle) # reads the tables with their titles # <markdowncell> # If you open the python file readhtml.py and look at the function titletable, you can see the function documentation. # # It says the following # <rawcell> # """return a list of [(title, table), .....] # title = previous item with a <b> tag # table = rows -> [[cell1, cell2, ..], [cell1, cell2, ..], ..]""" # # <markdowncell>
# Let us say you want to find the "Net Site Energy". # # This is in table "Site and Source Energy". # # The number you want is in the third row, second column and it's value is "47694.47" # # Let us use eppy to extract this number # <codecell> from eppy import readhtml # the eppy module with functions to read the html fname = "../eppy/resources/outputfiles/V_7_2/5ZoneCAVtoVAVWarmestTempFlowTable_ABUPS.html" # the html file you want to read filehandle = open(fname, 'r').read() # get a file handle to the html file htables = readhtml.titletable(filehandle) # reads the tables with their titles # <markdowncell> # If you open the python file readhtml.py and look at the function titletable, you can see the function documentation. # # It says the following # <rawcell> # """return a list of [(title, table), .....] # title = previous item with a <b> tag # table = rows -> [[cell1, cell2, ..], [cell1, cell2, ..], ..]""" # # <markdowncell>