Reputation: 57
my program shown below is one that reads data from a CSV file and imports it to PSSE
. PSSE
is a power flow simulation program. The program I have works.
My next goal is to read new data from new columns I put into my excel file COLUMNS[G to L]
. This data I am trying to implement into this function psspy.two_winding_chng(from_busnum, to_busnum,VMAX,VMIN,'character value')
Columns G through K are in order like the function value. The last parameter has to be implemented as a string value. So another thing is reading a variable on excel and transferring it as a string.
Finally my goal is to read data in Column G to L based off the program I have now where it takes the "year" and "location" and print out Columns B through E. Is there a way to do this? Also in Column L, that column represnts the data for the first, second, third year,etc.
Is there way to link column L and Column A. I can not use the xlrd, pandas modules or any other one, this the only module installed on the school computer. Excel sheet is posted. Columns A through L are described as:
"year","busnum","busname","change","tla","location","from","to","max","min", 'character value', "year_linkup"
. My CSV sheet is posted here.[Excel Sheet][1]
import os, sys
PSSE_LOCATION = r "C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
import redirect
import csv
psspy.throwPsseExceptions = True
from Tkinter
import *
import tkFileDialog
import tkSimpleDialog
import tkMessageBox
root = Tk()
tkMessageBox.showinfo("Welcome", "Please select case: ")
root.fileName = tkFileDialog.askopenfilename(filetypes = (("PSSE CASES",
"*.sav"), ("PSSE CASES", "*.raw*")))
STUDY_CASE = root.fileName
psspy.psseinit(10000)
psspy.case(STUDY_CASE)
LOAD_GEN_DATAFILE = 'C:\Users\RoszkowskiM\Documents\Working_Program\CSV.csv'
# read the entire CSV into Python.
data = list(csv.reader(open(LOAD_GEN_DATAFILE)))
mydict = {}
for row in data:
year, busnum, busname, change, tla, location = row[0: 6]# convert the types from string to Python numbers
# If this is a year not seen before, add it to the dictionary
if year not in mydict:
mydict[year] = {}
busses_in_year = mydict[year]
if location not in busses_in_year:
busses_in_year[location] = []
# Add the bus to the list of busses that stop at this location
busses_in_year[location].append((busnum, busname, change))
year = raw_input("Please Select Year of Study: ")
print("\n")
commands = ["Millwood-Buchanan", "Astoria-East-Corona", "Bronx",
"DUNWOODIE-North-Sherman_Creek",
"Vernon", "Greenwood-
StatenIsland ","
West_49th ","
East_13th ","
Staten_Island ","
East_River ",
"East_View", "DUNWOODIE-SOUTH", "Corona-Jamaica", "Astoria-East-Corona-
Jamaica ",
"Astoria-West-Queensbridge-Vernon", "Astoria-West-Queensbridge"
]
max_columns = 50
for index, commands in enumerate(commands):
stars_amount = max(max_columns - len(commands), 0)
row = "# {} {}({})".format(commands, "." * stars_amount, index + 1)
print(row)
location = raw_input(" \n The list above show the TLA Pockets as well as the ID numbers assigned to them ()\n\n Please enter the ID #: ")
print("\n")
# assume CSV has columns as described in the doc string
if year in mydict and location in mydict[year]:
busses_in_year = mydict[year]
print("Here are all the busses at that location for that year and the new LOAD TOTAL: ")
print("\n")
for busnum, busname, change in busses_in_year[location]:
change = float(change)
busnum = int(busnum)
print('Bus #: %d' % busnum, 'Area Station: %s' % busname, 'New_load: %d MW' % change)
psspy.bsys(1, 0, [0.0, 0.0], 0, [], 1, [busnum], 0, [], 0, [])
psspy.scal_2(1, 0, 1, [0, 0, 0, 0, 0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
psspy.scal_2(0, 1, 2, [0, 1, 0, 1, 0], [change, 0.0, 0, -.0])
Upvotes: 1
Views: 576