Python Forum
beginner level Python:- output XLS spreadsheet instead of using tabulate
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner level Python:- output XLS spreadsheet instead of using tabulate
#5
Now I would like to output to XLS workbook using 'xlwt' instead.
I would also like to keep the original headers
["MACADDRESS", "IPADDRESS", "INTERFACE","ENCAP", "TENANT", "APP PROFILE", "EPG"]

import xlwt
	wb = xlwt.Workbook()
	ws = wb.add_sheet('EndPoints')

	ws.write(--==Just working on this bit==--)

	wb.save('ACI-Endpoints.xls')  

(Jan-27-2018, 05:49 PM)j.crater Wrote: Thanks for posting your solution. I recommend you to alter the part of code you use to open and write to file. See here how context managers (with) are usually used with files.

is this better?

    # Write downloaded data to ACI-Endpoints.csv
    myFile = open('ACI-Endpoints.csv', 'w')
    with myFile as f:
    	writer = csv.writer(myFile)
    	writer.writerows(data)
    	f.closed
    	
Reply


Messages In This Thread
RE: beginner level Python:- output XLS spreadsheet instead of using tabulate - by haziebaby - Jan-27-2018, 05:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Counting of rows in Excel Spreadsheet dakrantau 2 1,941 Sep-30-2020, 02:27 AM
Last Post: dakrantau
  How do I write a line of code into an excel spreadsheet using Python code? Emerogork 2 3,155 Feb-07-2018, 06:54 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020