Exemplo n.º 1
0
def test_lines_table():
    """py.test for lines_table"""
    # soup = BeautifulSoup(SAMPLE_HTML)
    result = readhtml.lines_table(SAMPLE_HTML, False)
    assert result == [[[
        'Table of Contents',
        'Report: Annual Building Utility Performance Summary',
        'For: Entire Facility', 'Timestamp: 2014-01-13\n    16:47:19',
        'Values gathered over      8760.00 hours', 'Site and Source Energy'
    ], [['a', '2'], ['3', '4']]],
                      [['Site to Source Energy Conversion Factors'],
                       [['b', '6'], ['7', '8']]],
                      [[
                          'Report: COMPONENTS OF PEAK ELECTRICAL DEMAND',
                          'For: Meter', 'Timestamp: 2014-01-13\n    16:47:19',
                          'Custom Monthly Report'
                      ], [['c', '16'], ['17', '18']]],
                      [[
                          'Report: COMPONENTS OF PEAK NET ELECTRICAL DEMAND',
                          'For: Meter', 'Timestamp: 2014-01-13\n    16:47:19',
                          'Custom Monthly Report'
                      ], [['d', '26'], ['27', '28']]]]
Exemplo n.º 2
0
def test_lines_table():
    """py.test for lines_table"""
    # soup = BeautifulSoup(SAMPLE_HTML)
    result = readhtml.lines_table(SAMPLE_HTML, False)
    assert result == [[[u'Table of Contents', 
            u'Report: Annual Building Utility Performance Summary', 
            u'For: Entire Facility', 
            u'Timestamp: 2014-01-13\n    16:47:19', 
            u'Values gathered over      8760.00 hours', 
            u'Site and Source Energy'], 
        [[u'a', u'2'], [u'3', u'4']]], 
    [[u'Site to Source Energy Conversion Factors'], 
        [[u'b', u'6'], [u'7', u'8']]], 
    [[u'Report: COMPONENTS OF PEAK ELECTRICAL DEMAND', 
            u'For: Meter', 
            u'Timestamp: 2014-01-13\n    16:47:19', 
            u'Custom Monthly Report'], 
        [[u'c', u'16'], [u'17', u'18']]], 
    [[u'Report: COMPONENTS OF PEAK NET ELECTRICAL DEMAND', 
            u'For: Meter', 
            u'Timestamp: 2014-01-13\n    16:47:19', 
            u'Custom Monthly Report'], 
        [[u'd', u'26'], [u'27', u'28']]]]
Exemplo n.º 3
0
for_images = ex_inits
for_images.display_png(for_images.html_snippet2)  # display the image below

# <markdowncell>

# Notice that the HTML snippet shows a table with three lines above it. The first two lines have information that describe the table. We need to look at both those lines to understand what the table contains. So we need a different function that will capture all those lines before the table. The funtion lines_table() described below will do this.

# <codecell>

from eppy import readhtml  # the eppy module with functions to read the html

fname = "../eppy/resources/outputfiles/V_8_1/ASHRAE30pct.PI.Final11_OfficeMedium_STD2010_Chicago-baseTable.html"  # the html file you want to read
filehandle = open(fname, "r").read()  # get a file handle to the html file


ltables = readhtml.lines_table(filehandle)  # reads the tables with their titles

# <markdowncell>

# The html snippet shown above is the last table in HTML file we just opened. We have used lines_table() to read the tables into the variable ltables. We can get to the last table by ltable[-1]. Let us print it and see what we have.

# <codecell>

import pprint

pp = pprint.PrettyPrinter()
pp.pprint(ltables[-1])

# <markdowncell>

# We can see that ltables has captured all the lines before the table. Let us make our code more explicit to see this
Exemplo n.º 4
0
from eppy import ex_inits #no need to know this code, it just shows the image below
for_images = ex_inits
for_images.display_png(for_images.html_snippet2) # display the image below

# <markdowncell>

# Notice that the HTML snippet shows a table with three lines above it. The first two lines have information that describe the table. We need to look at both those lines to understand what the table contains. So we need a different function that will capture all those lines before the table. The funtion lines_table() described below will do this.

# <codecell>

from eppy import readhtml # the eppy module with functions to read the html
fname = "../eppy/resources/outputfiles/V_8_1/ASHRAE30pct.PI.Final11_OfficeMedium_STD2010_Chicago-baseTable.html" # the html file you want to read
filehandle = open(fname, 'r').read() # get a file handle to the html file


ltables = readhtml.lines_table(filehandle) # reads the tables with their titles

# <markdowncell>

# The html snippet shown above is the last table in HTML file we just opened. We have used lines_table() to read the tables into the variable ltables. We can get to the last table by ltable[-1]. Let us print it and see what we have.

# <codecell>

import pprint
pp = pprint.PrettyPrinter()
pp.pprint(ltables[-1])

# <markdowncell>

# We can see that ltables has captured all the lines before the table. Let us make our code more explicit to see this
Exemplo n.º 5
0
import matplotlib.pyplot as plt
pd.options.display.mpl_style = 'default'

pathnameto_eppy = '/Users/eayoungs/repo/Code/Simulation_Tools/Scripting/eppy/eppy'
sys.path.append(pathnameto_eppy)

from eppy import readhtml
iddfile = "/Users/eayoungs/Dropbox/SHARE/BSUG/Energy+.idd"

#IDF.setiddname(iddfile) # This only needs to be run the first time through

#=======================================================================================================================

htmlDoc = open('/Users/eayoungs/Dropbox/SHARE/BSUG/FinalModels/BaselineTable.html', 'r')
htmlContents = htmlDoc.read()
linesTable = readhtml.lines_table(htmlContents, True)

pp = pprint.PrettyPrinter(indent=4)

reportDict = {}
tableDict = {}
tableContents =[]
for i in range(len(linesTable)):
    reportHeader = linesTable[i][0]
    if any("Report: " in s for s in reportHeader):
        reportLst = [s for s in reportHeader if "Report: "]
        reportName = reportLst[0]
        tableName = reportHeader[len(reportHeader)-1]
        tableContents = linesTable[i][1]
        
        tableDict[tableName] = tableContents