Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

Here's some Python code that connects to the SQL database, queries it for the End Uses table, and writes it to a CSV file.

import os
import numpy as np
import pandas as pd
import sqlite3

sql_dir = r'C:\Users\Matt\Documents\WORKING\14038 NIST\14038-Baseline\run\6-EnergyPlus-0'
sql_file = 'eplusout.sql'
sql_path = os.path.join(sql_dir, sql_file)
print sql_path
write_dir = sql_dir

# Connect an create a cursor
conn = sqlite3.connect(sql_path)

#Create a cursor and return the list of all tables in the database
c = conn.cursor()

query = "SELECT * FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND TableName='End Uses'"
end_uses = pd.read_sql(query, conn)
end_uses.to_csv(os.path.join(write_dir, 'SQL-EndUses.csv'), index=False)
end_uses

Here's some old Python code that connects to the SQL database, queries it for the End Uses table, and writes it to a CSV file.

import os
import numpy as np
import pandas as pd
import sqlite3

sql_dir = r'C:\Users\Matt\Documents\WORKING\14038 NIST\14038-Baseline\run\6-EnergyPlus-0'
sql_file = 'eplusout.sql'
sql_path = os.path.join(sql_dir, sql_file)
print sql_path
write_dir = sql_dir

# Connect an create a cursor
conn = sqlite3.connect(sql_path)

#Create a cursor and return the list of all tables in the database
c = conn.cursor()

query = "SELECT * FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND TableName='End Uses'"
end_uses = pd.read_sql(query, conn)
end_uses.to_csv(os.path.join(write_dir, 'SQL-EndUses.csv'), index=False)
end_uses

Here's some old Python code that I had in a Jupyter notebook that connects to the SQL database, queries it for the End Uses table, and writes it to a CSV file.

# In[1]:

import os
import numpy as np
import pandas as pd
import sqlite3


# In[2]:

sql_dir = r'C:\Users\Matt\Documents\WORKING\14038 NIST\14038-Baseline\run\6-EnergyPlus-0'
sql_file = 'eplusout.sql'
sql_path = os.path.join(sql_dir, sql_file)
print sql_path
write_dir = sql_dir


# In[3]:

# Connect an create a cursor
conn = sqlite3.connect(sql_path)

#Create a cursor and return the list of all tables in the database
c = conn.cursor()


# In[4]:

query = "SELECT * FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND TableName='End Uses'"
end_uses = pd.read_sql(query, conn)
pd.read_sql(query ,conn)
end_uses.to_csv(os.path.join(write_dir, 'SQL-EndUses.csv'), index=False)
end_uses

Here's some old Python code that I had in a Jupyter notebook that connects to the SQL database, queries it for the End Uses table, and writes it to a CSV file.

# In[1]:

import os
import numpy as np
import pandas as pd
import sqlite3

 # In[2]:

sql_dir = r'C:\Users\Matt\Documents\WORKING\14038 NIST\14038-Baseline\run\6-EnergyPlus-0'
sql_file = 'eplusout.sql'
sql_path = os.path.join(sql_dir, sql_file)
print sql_path
write_dir = sql_dir
 
# In[3]:

# Connect an create a cursor
conn = sqlite3.connect(sql_path)

#Create a cursor and return the list of all tables in the database
c = conn.cursor()

 # In[4]:

query = "SELECT * FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND TableName='End Uses'"
end_uses = pd.read_sql(query ,conn)
end_uses.to_csv(os.path.join(write_dir, 'SQL-EndUses.csv'), index=False)
end_uses