• Increase font size
  • Default font size
  • Decrease font size
joomla templates, wordpress themes, drupal, datalife engine, graphics, seo,

Simple Example of Using the Eve API with Python and Excel

E-mail Print PDF

Here's an example of pushing Eve data into Excel using Python. Once again, I'm keeping this as simple as I can by not having any error checking or advanced functionality. I'm hoping this is a useful starting point for someone trying to get started with Eve and Python. I tried to make the code readable and comment it well so that it's self-explanatory. I'll explain a few points after the code though. If you have questions, leave a comment and I'll try my best to answer them. Also, you'll need to setup pywin32 for the Excel code to work.

The Code

import urllib
import xml.dom.minidom
import win32com.client
#Enter your UserID, API Key, and CharacterID here
CharacterID = 'XXXXXXXXX'
#Download the Account Balance Data
apiURL = '' % (UserID, Key, CharacterID)
downloadedData = urllib.urlopen(apiURL)
#Parse the data into the headers and lines of data
XMLData = xml.dom.minidom.parse(downloadedData)
headerNode = XMLData.getElementsByTagName("rowset")[0]
columnHeaders = headerNode.attributes['columns'].value.split(',')
dataNodes = XMLData.getElementsByTagName("row")
#Open or connect to Excel and create a new workbook. Use the active sheet in the new workbook.
Excel = win32com.client.Dispatch("Excel.Application")
Excel.Visible = True
ThisWorkbook = Excel.Workbooks.Add()
ThisSheet = ThisWorkbook.ActiveSheet
#Put headers across the top of the sheet. I'm going to skip formatting the headers for this example
for col, header in enumerate(columnHeaders):
    ThisSheet.Cells(1, col + 1).Value = header
#Fill out the data below the headers
for row, dataNode in enumerate(dataNodes):
    for col, columnHeader in enumerate(columnHeaders):
        ThisSheet.Cells(row + 2, col+1).Value = dataNode.attributes[columnHeader].value



ThisSheet.Cells(1, col + 1).Value = header

Lists in Python start at index 0. Rows and Columns in Excel start at 1. So in a couple places in this code you'll see an extra +1. If you try to use cell 0,0 it will cause an error.

It is possible to grab the Excel sheet that was open or to open one from file instead of creating a new one. Sometimes I create a formatted Excel sheet to load the data into rather than formatting the sheet in code. To use a sheet that's already open replace the Excel code block with this:

Excel = win32com.client.Dispatch("Excel.Application")
Excel.Visible = True
ThisSheet = Excel.ActiveSheet

Keep in mind this will overwrite data in your Excel sheet so make sure you have the right sheet selected before running the code. Also, it will error out if there is no Excel sheet open on your system.

Since the headers are read from the downloaded XML, this code will work with other APIs if you change the download portion. You just need to make sure you build the right URL for the API you want.

Last Updated on Friday, 10 June 2011 15:33  


0 #57 Pld temic fix 2017-11-20 02:06
You could certainly see your expertise inn the articcle you write.
The world hopes for more passionate writers such as you who aren't afraid too saay
hhow they believe. All thhe time go after your heart.
0 #56 Angelika 2017-09-28 06:53
Nice post. I was checking constantly this blog
and I'm impressed! Very helpful information paticularly the last part :
) I care for such info much. I was seeking this certai informatio for a vey long time.
Thank you and best off luck.
0 #55 Loreen 2017-09-24 20:31
I think other web-site proprietors should take this website as an model,
very clean and great user friendly style and design, as well as the content.
You are an expert in this topic!
0 #54 FastKala 2017-09-20 14:19
I see you don't monetize your page, don't waste your traffic,
you can earn additional bucks every month because you've
got high quality content. If you want to know how to make extra bucks, search
for: best adsense alternative Dracko's tricks
0 #53 Robert 2017-09-15 00:41
May I just say what a comfort to discover somebody who actually knows what they are talking about online.
You certainly know how to bring an issue to light and make it important.
A lot more people must check this out and understand this side of the
story. I can't believe you're not more popular given that you certainly
possess the gift.

Feel free to surf to my blog: Robert:
0 #52 42163057900 2017-09-13 13:50
Hi there, I found your website via Google
even as looking for a comparable topic, your web site came up, it seems great.
I have bookmarked it in my google bookmarks.
Hi there, simply was aware of your weblog thru Google,
and located that it's really informative. I am going to watch
out for brussels. I will be grateful if you happen to proceed
this in future. Lots of other folks shall be benefited from your writing.
0 #51 86Wiley 2017-09-03 16:12
I have noticed you don't monetize your blog, don't waste your traffic,
you can earn additional cash every month because you've got high quality content.

If you want to know how to make extra bucks,
search for: best adsense alternative Wrastain's tools
0 #50 Horacio 2017-08-04 13:03
Its such ass you learn my mind! You appear to know a lot about
this, such as you wrote the e-book iin it or something. I believe that
yyou just can do with some percent to drive the message house a bit,
but instead of that, that is fantastic blog. An excellent read.
I'll certainky bee back.

my web page - ?????? ??????? ? ???????? - Horacio:,
0 #49 backlinks 2017-08-01 21:12
That may be the milli?n ?ollar question and it is what I'd like to speak about
on this page today. Unrelated and random links from any old site ?ill not make Google see youjr site to
important. This tool can be VER? valuable when planning your search engine ?ptimiz?tion marketing.

my web-site; ?acklinks:
0 #48 Ramon 2017-08-01 02:49
Hi everybody, here every one is sharing these kinds of know-how, therefore it's nice to read this website, and I used to pay a
quick visit this webpage everyday.

Here is my web site; Ramon:

Add comment

Security code

Main Menu