473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Exporting NumPy data to excel

3
I have a series of arrays that I would like to send to excel for display and processing

After spending most of the evening google I cant find anything out there that gives an example to what I looking for even just to send a series of values to a range in excel would be good all I can do at the moment is open an excel application

import win32com.client
excel = win32com.client.Dispatch("Excel.Application")
excel.Visible = 1
workbook=excel.Workbooks.Open('C:\DATA/Book1.xls')

excel.Range("B3").Select
excel.ActiveCell.FormulaR1C1 = "2"
excel.Range("B4").Select
excel.ActiveCell.FormulaR1C1 = "4"


any idea with some code would be good

have come across
pyExcelerator but cant get any examples that are relatively straight forward to understand

tks
M
Feb 26 '07 #1
5 9787
bvdet
2,851 Expert Mod 2GB
I have a series of arrays that I would like to send to excel for display and processing

After spending most of the evening google I cant find anything out there that gives an example to what I looking for even just to send a series of values to a range in excel would be good all I can do at the moment is open an excel application

import win32com.client
excel = win32com.client.Dispatch("Excel.Application")
excel.Visible = 1
workbook=excel.Workbooks.Open('C:\DATA/Book1.xls')

excel.Range("B3").Select
excel.ActiveCell.FormulaR1C1 = "2"
excel.Range("B4").Select
excel.ActiveCell.FormulaR1C1 = "4"


any idea with some code would be good

have come across
pyExcelerator but cant get any examples that are relatively straight forward to understand

tks
M
I don't know numPy, but it should be straightforward to write the data to a tab delimited file. In explorer - right click on the file - open in Excel.
Feb 26 '07 #2
bartonc
6,596 Expert 4TB
I have a series of arrays that I would like to send to excel for display and processing

After spending most of the evening google I cant find anything out there that gives an example to what I looking for even just to send a series of values to a range in excel would be good all I can do at the moment is open an excel application

import win32com.client
excel = win32com.client.Dispatch("Excel.Application")
excel.Visible = 1
workbook=excel.Workbooks.Open('C:\DATA/Book1.xls')

excel.Range("B3").Select
excel.ActiveCell.FormulaR1C1 = "2"
excel.Range("B4").Select
excel.ActiveCell.FormulaR1C1 = "4"


any idea with some code would be good

have come across
pyExcelerator but cant get any examples that are relatively straight forward to understand

tks
M
>>> import numpy
>>> ADData = numpy.zeros((4, 4), dtype=numpy.int16)

Loop through the array converting indexes and values to string:

>>> for i, row in enumerate(ADData):
... for j, cell in enumerate(row):
... print "R%dC%d = %d" %(i, j, cell)
...
R0C0 = 0
R0C1 = 0
R0C2 = 0
R0C3 = 0
R1C0 = 0
R1C1 = 0
R1C2 = 0
R1C3 = 0
R2C0 = 0
R2C1 = 0
R2C2 = 0
R2C3 = 0
R3C0 = 0
R3C1 = 0
R3C2 = 0
R3C3 = 0
Feb 26 '07 #3
bartonc
6,596 Expert 4TB
>>> import numpy
>>> ADData = numpy.zeros((4, 4), dtype=numpy.int16)

Loop through the array converting indexes and values to string:

>>> for i, row in enumerate(ADData):
... for j, cell in enumerate(row):
... print "R%dC%d = %d" %(i, j, cell)
...
R0C0 = 0
R0C1 = 0
R0C2 = 0
R0C3 = 0
R1C0 = 0
R1C1 = 0
R1C2 = 0
R1C3 = 0
R2C0 = 0
R2C1 = 0
R2C2 = 0
R2C3 = 0
R3C0 = 0
R3C1 = 0
R3C2 = 0
R3C3 = 0
or:
>>> for i, row in enumerate(ADData):
... for j, cell in enumerate(row):
... print "R%dC%d = %s" %(i, j, repr(str(cell)))
...
R0C0 = '0'
R0C1 = '0'
R0C2 = '0'
R0C3 = '0'
R1C0 = '0'
R1C1 = '0'
R1C2 = '0'
R1C3 = '0'
R2C0 = '0'
R2C1 = '0'
R2C2 = '0'
R2C3 = '0'
R3C0 = '0'
R3C1 = '0'
R3C2 = '0'
R3C3 = '0'
Feb 26 '07 #4
jonas
3
or:
>>> for i, row in enumerate(ADData):
... for j, cell in enumerate(row):
... print "R%dC%d = %s" %(i, j, repr(str(cell)))
...
R0C0 = '0'
R0C1 = '0'
R0C2 = '0'
R0C3 = '0'
R1C0 = '0'
R1C1 = '0'
R1C2 = '0'
R1C3 = '0'
R2C0 = '0'
R2C1 = '0'
R2C2 = '0'
R2C3 = '0'
R3C0 = '0'
R3C1 = '0'
R3C2 = '0'
R3C3 = '0'

And the line sending all this to excel - iterating over the array its sending it to an excel file that I have the problems with
Feb 27 '07 #5
bartonc
6,596 Expert 4TB
And the line sending all this to excel - iterating over the array its sending it to an excel file that I have the problems with
Sorry, I don't know any Visual Basic. I think that Paste might work, though.
Feb 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hideyuki | last post by:
Hi, I am using asp.net, and I am having a problem exporting datagrid to excel. One column contains numbers such as 123456875468. When this goes to excel, it is displayed as 1.23456E + 11 which I...
5
by: Anthony | last post by:
First time here so please bear with me. Set up a DTS package to export data to an excel sheet on an hourly basis. Problem is, it keeps appending to the same excel sheet. Any idea how to...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
0
by: Sridhar | last post by:
Hi, I am having trouble renaming the excel sheet while exporting to excel. we have a datagrid that contains some analytical data. I have the name to the excel file as "temp.xls" inside the code....
7
by: semijoyful | last post by:
OS: Win XP SP2 Access version: 2003 Excel version: 2003 I am new at this, as I am sure you have gathered from this post title:) I am working on a form where users can input data in Access and...
3
by: jennwilson | last post by:
Access 2000 - I have developed a database that houses patient information. The patient information must be sent in an excel file to another company department. I know how to export my data to Excel...
2
by: eskelies | last post by:
Hello all, I have data, which is separated into account numbers (ie. 10, 20, 30), but it exists in one query. Right now, I have an access macro "transferspreadsheet," which is exporting all the...
2
by: billkeziah | last post by:
I am exporting data from an HTML table to MS Excel using ASP. Everything works fine except that data that is in one HTML cells separated by the "<BR>" export to MS Excel in 2 separate data cells in...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.