1

下面显示的我的程序是从 CSV 文件中读取数据并将其导入到PSSE. PSSE是一个潮流模拟程序。我的程序有效。

我的下一个目标是从我放入 excel 文件的新列中读取新数据COLUMNS[G to L]。我试图将这些数据实现到这个函数psspy.two_winding_chng(from_busnum, to_busnum,VMAX,VMIN,'character value')中 G 到 K 列的顺序与函数值类似。最后一个参数必须实现为字符串值。所以另一件事是在 excel 上读取一个变量并将其作为字符串传输。

最后,我的目标是根据我现在拥有的程序读取 G 列到 L 列中的数据,它需要“年份”和“位置”并打印出 B 列到 E 列。有没有办法做到这一点?同样在 L 列中,该列表示第一年、第二年、第三年等的数据。

有没有办法链接 L 列和 A 列。我不能使用xlrdpandas模块或任何其他模块,这是学校计算机上唯一安装的模块。Excel 表已发布。A 到 L 列描述为: "year","busnum","busname","change","tla","location","from","to","max","min", 'character value', "year_linkup"。我的 CSV 表张贴在这里。[Excel 表][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])
4

0 回答 0