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

Revision history [back]

Simply save the IDF using eppy, it sorts automatically

        idf = IDF(idfpath)
        idf.saveas(idfpath)

Simply save the IDF using eppy, it sorts automatically

        idf = IDF(idfpath)
        idf.saveas(idfpath)

Here's an entire script to sort all the IDF files that are in the same folder as the python file:

       from eppy import modeleditor
       from eppy.modeleditor import IDF
       import os
       iddfile = "C:/EnergyPlusV9-0-1/Energy+.idd"
       IDF.setiddname(iddfile)
       dir = os.path.dirname(os.path.realpath(__file__))
       for path, subdirs, files in os.walk(dir):
           for name in files:
               ext = os.path.splitext(name)[-1].lower()
               if ext == ".idf":
                   idfpath = os.path.join(path, name)
                   idf = IDF(idfpath)
                   idf.saveas(idfpath)