473,770 Members | 4,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pyExcelerator: writing multiple rows

Hi all,

I was just curious if there was a built-in or a more efficient way to
do take multiple rows of information and write them into excel using
pyExcelerator. This is how I resolved the problem:

from pyExcelerator import *

data = [[1,2,3],[4,5,'a'],['','s'],[6,7,'g']]

wb=pyExcelerato r.Workbook()
test = wb.add_sheet("t est")

c=1
r=0
while r<len(data):
for d in data[r]:
test.write(r,c, d)
c+=1
r+=1
c=1
wb.save('c:\\1\ \test.xls')
Jan 19 '08 #1
1 2294
On Jan 19, 7:46�am, patrick.wa...@g mail.com wrote:
Hi all,

I was just curious if there was a �built-in or a more efficient way to
do take multiple rows of information and write them into excel using
pyExcelerator. �This is how I resolved the problem:

from pyExcelerator import *

data = [[1,2,3],[4,5,'a'],['','s'],[6,7,'g']]

wb=pyExcelerato r.Workbook()
test = wb.add_sheet("t est")

c=1
r=0
while r<len(data):
� � for d in data[r]:
� � � � test.write(r,c, d)
� � � � c+=1
� � r+=1
� � c=1
wb.save('c:\\1\ \test.xls')
Try this:

for row,rowdata in enumerate(data) :
for col,cell in enumerate(rowda ta):
test.write(row, col,cell)
If you need row & col offsets, add them.

row_offset = 7
col_offset = 3
for row,rowdata in enumerate(data) :
for col,cell in enumerate(rowda ta):
test.write(row+ row_offset,col+ col_offset,cell )
Jan 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3647
by: Marco Aschwanden | last post by:
Hi, Yesterday I placed a bug report on PyExcelerators-Sourceforge-page... but I am not so sure anymore, whether this is really a bug - I could imagine that I missed something, but I don't see what. Please confirm that my bug is due to mishandling and I will gladly retreat my bug report. In a formula, I would like to point to a field on another worksheet. pyExcelerator chokes on these references!
3
7203
by: tkpmep | last post by:
I downloaded PyExcelerator.zip as I need to write some data into Excel files, and tried unsuccessfully to install it. I unzipped the files into C:/Python24/Lib/site-packages/PyExcelerator, and in a python command line window typed >>>os.chdir("C:/Python24/Lib/site-packages/PyExcelerator") followed by >>>python ./setup.py install
2
10399
by: tkpmep | last post by:
I have just installed PyExcelerator, and now want to use it to read Excel spreadsheets with a variable number of rows and columns and with multiple sheets. Unfortunately, no documentation seems to accompany PyExcelerator. Does anyone know of a good source of documentations and/or examples? The author provides some examples, but these tend to involve writing data into spreadsheets one cell at a time. Thanks in advance Thomas Philips
1
3267
by: tkpmep | last post by:
I write data to Excel files using PyExcelerator 0.6.3.a and have done so successfully for small files (10-15 cells). I'm experiencing an error when writing a big chunk of data (10,000 cells) to Excel. By way of comparison, the same data writes perfectly well to a csv file using Python's built in csv module. I run the program in PyScripter, and the traceback shows the following sequence of calls: main (my routine)...
4
5845
by: Marco Aschwanden | last post by:
Hi I would like to 1. import an existing Excel-sheet (a template) 2. and add some data to it 3. and save it under a different name afterwards. To me it seems, that pyExcelerator does not support the reading for modification of an Excel-sheet. It allows only the "parse_xls" but I would like to keep the "formatting" in the template.
3
13606
by: implicate_order | last post by:
Greetings, I'm new to python and am in the process of writing a script to parse some CSV data, spread it across multiple Excel worksheets and then generate charts. I searched the internet to find some place where I could look up a HOWTO doc/recipe to do that using either pyExcelerator or win32com.client. Could someone point me in the right direction? I'm at the stage where the spreadsheet and associated data worksheets
5
8087
by: susan | last post by:
Hi, I'm new of Python, and this problem stucked me whole day but can't be solved. I use python 2.4.3, which is download from cygwin packages. Then I downloaded pyexcelerator-0.5.3a, unzip it, $ python ./pyExcelerator/setup.py install running install running build
3
1772
by: tkpmep | last post by:
My program creates three lists: the first has dates expressed as strings, the second has floats that are strictly positive, and the third has floats that are strictly negative. I have no trouble writing the data in these lists to a .csv file using the csv module using the following code. outfile = file(fn + '.csv','wb') writer = csv.writer(outfile) for i in range(len(dateList)): writer.writerow(, posVals, negVals])
1
2385
by: aneesh.goel.rbtx | last post by:
I'm using pyExcelerator to take a folder of CSV files and create Excel workbooks for all of them, then generate an Excel workbook with the data from all of them. Everything up until here works great; next, I make a second worksheet on the last workbook which has summary details regarding the previous worksheet. Here I run into a problem. The Excel form AVERAGE(Data!E5:E3053)
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.