<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Useful Scripts
Location of the scripts
Here are some scripts that you may find useful. They are in the folder "./eppy/useful_scripts"
And now for some housekeeping before we start off
Step1:  If you look in the folder "./eppy/useful_scripts", you fill find the following scripts
The scripts are
Step2:  That was useful !
Now let us try running the program
Step3:  Redirecting output to a file
Most scripts will print the output to a terminal. Sometimes we want to send the output to a file, so that we can save it for posterity. We can do that py using ">" with the filename after that. For eppy_version.py, it will look like this
Step4:  Now let us try this with two "idf" files that are slightly different. If we open them in a file comparing software, it would look like this
Step5:  There are 4 differences between the files. Let us see what idfdiff.py does with the two files. We will use the --html option to print out the diff in html format.
Step6:  It does look like html 
Step7:  Pretty straight forward. Scroll up and look at the origin text files, and see how idfdiff.py understands the difference
Now let us try the same thin in csv format
Step8:  We see the same output, but now in csv format. You can redirect it to a ".csv" file and open it up as a spreadsheet
loopdiagram.py
Diagrams of HVAC loops
This script will draw all the loops in an idf file. It is a bit of a hack. So it will work on most files, but sometimes it will not 
Step9:  Pretty straightforward. Simply open png file and you will see the loop diagram. (ignore the dot file for now. it will be documented later)
So let us try this out with and simple example file. We have a very simple plant loop in "../resources/idffiles/V_7_2/plantloop.idf"
Step10:  The script prints out it's progress. On larger files, this might take a few seconds. If we open this file, it will look like the diagram below
Note
<ASSISTANT_TASK:>
Python Code:
import os
os.chdir("../eppy/useful_scripts")
# changes directory, so we are where the scripts are located
# you would normaly install eppy by doing
# python setup.py install
# or
# pip install eppy
# or
# easy_install eppy
# if you have not done so, the following three lines are needed
import sys
# pathnameto_eppy = 'c:/eppy'
pathnameto_eppy = '../../'
sys.path.append(pathnameto_eppy) 
Explanation: Useful Scripts
Location of the scripts
Here are some scripts that you may find useful. They are in the folder "./eppy/useful_scripts"
And now for some housekeeping before we start off
End of explanation
%%bash
# ignore the line above. It simply lets me run a command line from ipython notebook
python eppy_version.py --help
Explanation: If you look in the folder "./eppy/useful_scripts", you fill find the following scripts
The scripts are:
- eppy_version.py
- idfdiff.py
- loopdiagram.py
- eppyreadtest_folder.py
- eppyreadtest_file.py
eppy_version.py
Many scripts will print out some help information, if you use the --help option. Let us try that
End of explanation
%%bash
# ignore the line above. It simply lets me run a command line from ipython notebook
python eppy_version.py
Explanation: That was useful !
Now let us try running the program
End of explanation
%%bash
# ignore the line above. It simply lets me run a command line from ipython notebook
python idfdiff.py -h
Explanation: Redirecting output to a file
Most scripts will print the output to a terminal. Sometimes we want to send the output to a file, so that we can save it for posterity. We can do that py using ">" with the filename after that. For eppy_version.py, it will look like this:
Some of the following scripts will generate csv or html outputs. We can direct the output to a file with .html extension and open it in a browser
Compare two idf files - idfdiff.py
This script will compare two idf files. The results will be displayed printed in "csv" format or in "html" format. 
You would run the script from the command line. This would be the terminal on Mac or unix, and the dos prompt on windows. Let us look at the help for this script, by typing:
End of explanation
from eppy.useful_scripts import doc_images #no need to know this code, it just shows the image below
for_images = doc_images
for_images.display_png(for_images.filemerge) # display the image below
Explanation: Now let us try this with two "idf" files that are slightly different. If we open them in a file comparing software, it would look like this:
End of explanation
%%bash
# python idfdiff.py idd file1 file2
python idfdiff.py --html --idd ../resources/iddfiles/Energy+V7_2_0.idd ../resources/idffiles/V_7_2/constructions.idf ../resources/idffiles/V_7_2/constructions_diff.idf 
Explanation: There are 4 differences between the files. Let us see what idfdiff.py does with the two files. We will use the --html option to print out the diff in html format.
End of explanation
from eppy.useful_scripts import doc_images #no need to know this code, it just shows the image below
from IPython.display import HTML
h = HTML(open(doc_images.idfdiff_path, 'r').read())
h
Explanation: It does look like html :-). We need to redirect this output to a file and then open the file  in a browser to see what it looks like. Displayed below is the html file
End of explanation
%%bash
# python idfdiff.py idd file1 file2
python idfdiff.py --csv --idd ../resources/iddfiles/Energy+V7_2_0.idd ../resources/idffiles/V_7_2/constr.idf ../resources/idffiles/V_7_2/constr_diff.idf
Explanation: Pretty straight forward. Scroll up and look at the origin text files, and see how idfdiff.py understands the difference
Now let us try the same thin in csv format
End of explanation
%%bash
# ignore the line above. It simply lets me run a command line from ipython notebook
python loopdiagram.py --help
Explanation: We see the same output, but now in csv format. You can redirect it to a ".csv" file and open it up as a spreadsheet
loopdiagram.py
Diagrams of HVAC loops
This script will draw all the loops in an idf file. It is a bit of a hack. So it will work on most files, but sometimes it will not :-(. But it is pretty useful when it works. 
If it does not work, send us the idf file and we'll try to fix the code
Make sure grapphviz is installed for this script to work
Again, we'll have to run the script from the terminal. Let us look at the help for this script
End of explanation
%%bash
# ignore the line above. It simply lets me run a command line from ipython notebook
python loopdiagram.py ../resources/iddfiles/Energy+V7_2_0.idd ../resources/idffiles/V_7_2/plantloop.idf
Explanation: Pretty straightforward. Simply open png file and you will see the loop diagram. (ignore the dot file for now. it will be documented later)
So let us try this out with and simple example file. We have a very simple plant loop in "../resources/idffiles/V_7_2/plantloop.idf"
End of explanation
from eppy.useful_scripts import doc_images #no need to know this code, it just shows the image below
for_images = doc_images
for_images.display_png(for_images.plantloop) # display the image below
Explanation: The script prints out it's progress. On larger files, this might take a few seconds. If we open this file, it will look like the diagram below
Note: the supply and demnd sides are not connected in the diagram, but shown seperately for clarity
End of explanation
<END_TASK>