I have an excel spreadsheet that has 2 used columns. Using Python I have to read the data in those to columns. So far I have a code that lists the item in column A and B on Python GUI. Once that is done I have to write code so that it takes that information and writes into Notepad in a certain way.
So far the code i have that read and print the excel information and actually works is:
1. def excel():
2. from win32com.client import Dispatch
3. xlApp = Dispatch ("Excel.Application") #Calls for Excel
4. xlWb = xlApp.Workbooks.Open('IT.xls') #It finds the workbook
5. xlSht = xlWb.Worksheets (1) Goes to sheet 1
6. dataList = []
7. for row in range (1,198): #It goes through the 198 items in A and B
8. for col in (1,2):
9. dataList.append(xlSht.Cells(row,col))
10. for item in dataList:
11. print item
I just have a simple code for notepad but i do not know how to integrate them:
1. def notepad():
2. print
3. text_file = open("write.txt","w")
4. lines = ["Line 1/n",
5. "This is line 2"]
6. text_file.writelines(lines)
7. text_file.close()
The information needs to appear in notepad in this format without the numbers on the left.
{
define host
use generic-AP
host_name Router Name
alias Router Name
address IP Address
}
Router name and IP Address changes but everything else remains the same. This needs to get repeated for cells. So in essence this needs to get repeated 198 times.