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

Suppose I have 100 variables calculated using Energyplus and I want to print the 100 in 10 CSV files, how may I achieve it ?

asked 2018-07-13 23:31:10 -0500

Siv gravatar image

Suppose I have 100 variables calculated using Energyplus and I want to print the 100 in 10 CSV files in such a way that each CSV file contains only 10 variables, how may I achieve it ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2018-07-16 02:58:40 -0500

updated 2018-07-16 03:11:24 -0500

Python and pandas would do that quite easily. This code will output as many csv files as needed regardless of your actual number of variables, each file with 10 variables (except the latest which could have between 1 and 10). Each will be named like eplusout_0.csv, eplusout_1.csv, etc.

import pandas as pd
import numpy as np

df = pd.read_csv('eplusout.csv', index_col=0)
# Chunck size
n = 10
for i in range(0, df.shape[1], n):
    df_chunck = df.iloc[:, i:i+n]
    df_chunck.to_csv('eplusout_{}.csv'.format(i))

Note: If you wanted, you do a bit better to properly parse the Date/Time CSV column as a valid DateTimeIndex.


I'll allow myself to go into a small rant here: the time conventions used by E+ as a MAJOR pain. The Date/Time index doesn't include the year, but more importantly it uses end of timestep conventions AND labels midnight as "24:00". Try to parse that in Python, you'll see.

In [1]
def dateparse(x):          
    return pd.datetime.strptime("2005/{}".format(x.strip()), '%Y/%m/%d %H:%M:%S')

df = pd.read_csv('eplusout.csv', index_col=0, parse_dates=True, date_parser=dateparse)

Out[1]:
ValueError: time data '2005/01/01  24:00:00' does not match format '%Y/%m/%d %H:%M:%S'

This is because datetime logically expects 0-23 for hour.

In [2]: import datetime
        datetime.datetime(2005, 1, 1, 24, 0, 0)

Out[2]: ValueError: hour must be in 0..23
edit flag offensive delete link more

Comments

1

FYI: https://github.com/NREL/EnergyPlus/is... (should probably be tagged 'NewFeatureRequest')

Eric Ringold gravatar imageEric Ringold ( 2018-07-16 10:11:40 -0500 )edit

Go upvote this issue please!

Julien Marrec gravatar imageJulien Marrec ( 2018-07-17 02:25:58 -0500 )edit

The utility that is responsible for converting the ESO (which has dates and times that make sense internally to E+) into CSV is ReadVarsESO. Yes, it is in F90, but it is open source and we are happy to take contributions (even in other programming languages). The contribution policy is right here.

Jason DeGraw gravatar imageJason DeGraw ( 2018-07-17 09:57:09 -0500 )edit

Jason, I'll answer on the Github Issue here

Julien Marrec gravatar imageJulien Marrec ( 2018-07-18 02:46:48 -0500 )edit
2

answered 2018-07-14 12:23:48 -0500

Avi gravatar image

updated 2018-07-14 12:24:55 -0500

I would import the csv file into Excel and then separate whatever I need into different worksheets.

That should be quiet easy to do. You could write simple macro script to automate that.

You could also run simulation 10 times each time with different output list but that is inefficient.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 



Question Tools

2 followers

Stats

Asked: 2018-07-13 23:31:10 -0500

Seen: 107 times

Last updated: Jul 16