Python Excel程序

我下面显示的程序是从CSV文件读取数据并将其导入PSSEPSSE是一个潮stream模拟程序。 我有程序的作品。

我的下一个目标是读取新列中的新数据,并将其放入我的excel文件COLUMNS[G to L] 。 这个数据,我试图实现到这个函数psspy.two_winding_chng(from_busnum, to_busnum,VMAX,VMIN,'character value')列G到K是为了像函数值。 最后一个参数必须作为string值来实现。 所以另外一件事就是读一个excel的variables并把它作为一个string传递。

最后,我的目标是读取列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 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])