title: Reading Excel Files/win32com.client
body: <p>I am writing a code where I link Excel into PSSE. I am using the <code>win32</code> module because my school does not allow use of the modules <code>xlrd</code>, <code>openpyxl</code>, and <code>csv</code>. So my goal in the code was to initially read the excel file using <code>win32</code> module. </p>
  
  <p>It read the files but I am trying to do the following:</p>
  
  <ul>
  <li>read the first column so it would represent the <em>year</em></li>
  <li>second column is <em>bus number</em></li>
  <li>third column is <em>bus name</em></li>
  <li>fourth column is <em>Power</em></li>
  <li>sixth column is <em>Area</em></li>
  <li>last column is <em>location ID</em>. </li>
  </ul>
  
  <p>I have posted a snippet of the excel sheet of the format of my page. My next goal is to link year and location together as the criteria for finding the <em>busnum, busname,</em> and <em>power</em>. I would use a <code>raw_input()</code> for the <em>year</em> and the <em>location</em> and if <em>location</em> and <em>year</em> are entered, the output should give me the <em>bus number</em>, <em>bus name</em>, and <em>power</em>. </p>
  
  <p>My code is shown below and this is was my idea for doing code. It does not run and I tried everything and nothing works.</p>
  
  <p><a href="https://i.stack.imgur.com/FPLxk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPLxk.jpg" alt="Excel Sheet"></a></p>
  
  <pre><code>import os, sys
  import psspy
  import win32com.client
  from win32com.client import Dispatch
  
  PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
  sys.path.append(PSSE_LOCATION)
  os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
  
  xlApp = Dispatch ("Excel.Application")   #Calls for Excel
  xlWb = xlApp.Workbooks.Open('Load forecast 12152016.xlsx')    #It finds the workbook
  xlSht = xlWb.Worksheets (18)   
  dataList = []
  
  for row in range (2,760): #It goes through the 758 items in A and B
      for col in (1,2,3,4,5):
           dataList.append(xlSht.Cells(row,col))
  
  mydict = {}
  for row in dataList:
      year = xlSht.Cells[1:760,1]
      busnnum = row[B2:B760]
      busname = row[C2:C760]
      Power = row[D2:D760]
      Area = row[E2:E760]
      location = row[F2:F760]
  
  # convert the types from string to Python numbers
  
  change= float(change)
  bus = int(busnum)
  
  #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,power))
  
  year = raw_input("Please Select Year of Study: ")
  print("\n")
  
  commands = ["M", "As", "Br", "D",
              "V", "G","W","E","S","E",
              "Ea","DU","Cor","Asto",
              "AV","A"]
  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,0.0,-.0,0])
  </code></pre>