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

Revision history [back]

Python and pandas would do that quite easily.

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+n]
    df_chunck.to_csv('eplusout_{}.csv'.format(i))

Python and pandas would do that quite easily.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+n]
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

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