473,480 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Extended zip() for lists

Hello,

I have 4 lists: a, b, c and d
Out of this 4 lists I want to build a table (e.g. list of lists):

a|b|c|d
---------------------------
a1|b1|c1|d1
a1|b2| |d2

You see: the lists are not equally sized.
Is there a command which fills up the shorter lists with blanks?
Like an enhanced zip() command, maybe?

Regards
Florian Reiser

--
http://www.ra-bc.de
RA Unternehmensberatung
Führen durch präzise Daten
Jun 8 '06 #1
4 1669

Florian Reiser wrote:
Hello,

I have 4 lists: a, b, c and d
Out of this 4 lists I want to build a table (e.g. list of lists):

a|b|c|d
---------------------------
a1|b1|c1|d1
a1|b2| |d2

You see: the lists are not equally sized.
Is there a command which fills up the shorter lists with blanks?
Like an enhanced zip() command, maybe?


map(None, list1, list2, list3)

http://aspn.activestate.com/ASPN/Coo.../Recipe/410687

Jun 8 '06 #2
Florian Reiser wrote:
I have 4 lists: a, b, c and d
Out of this 4 lists I want to build a table (e.g. list of lists):

a|b|c|d
---------------------------
a1|b1|c1|d1
a1|b2| |d2

You see: the lists are not equally sized.
Is there a command which fills up the shorter lists with blanks?
Like an enhanced zip() command, maybe?


like map(None, ...), perhaps ?
a = "1234"
b = "12"
c = "123"
d = "1234"
zip(a, b, c, d) [('1', '1', '1', '1'), ('2', '2', '2', '2')] map(None, a, b, c, d)

[('1', '1', '1', '1'), ('2', '2', '2', '2'), ('3', None, '3', '3'),
('4', None, None, '4')]

</F>

Jun 8 '06 #3
Florian Reiser wrote:
Hello,

I have 4 lists: a, b, c and d
Out of this 4 lists I want to build a table (e.g. list of lists):

a|b|c|d
---------------------------
a1|b1|c1|d1
a1|b2| |d2

You see: the lists are not equally sized.
Is there a command which fills up the shorter lists with blanks?
Like an enhanced zip() command, maybe?

Regards
Florian Reiser


I posted a function to do this back in January. See:

http://groups.google.co.uk/group/com...d1541e632adfdd
Jun 8 '06 #4
Hello Gene,

a big THANKS for this tip. This is exactly what I was looking for.

Regards

Florian Reiser

"gene tani" <ge*******@gmail.com> schrieb im Newsbeitrag
news:11*********************@i39g2000cwa.googlegro ups.com...

Florian Reiser wrote:
Hello,

I have 4 lists: a, b, c and d
Out of this 4 lists I want to build a table (e.g. list of lists):

a|b|c|d
---------------------------
a1|b1|c1|d1
a1|b2| |d2

You see: the lists are not equally sized.
Is there a command which fills up the shorter lists with blanks?
Like an enhanced zip() command, maybe?


map(None, list1, list2, list3)

http://aspn.activestate.com/ASPN/Coo.../Recipe/410687

Jun 9 '06 #5

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

Similar topics

3
3315
by: Matt Gerrans | last post by:
This is probably so easy that I'll be embarrassed by the answer. While enhancing and refactoring some old code, I was just changing some map()s to list comprehensions, but I couldn't see any easy...
0
1785
by: Charles Parker | last post by:
Does MySQL have support for calling functions in C/C++ DLLs from trigger scripts similar to the Extended Stored Procedures functionality provided in SQL Sever? Thanks. Charles... -- MySQL...
1
4392
by: WangKhar | last post by:
Hi (sorry this has turned into a bit of an epic...thought I'd as the experts!) SQL 2k, sp3a. Dual xeon 2.4. 2 gig ram. everything on a 3 disk raid 5. Microsoft SQL Server 2000 - 8.00.760...
18
1263
by: Istvan Albert | last post by:
Hello all, I've been debugging the reason for a major slowdown in a piece of code ... and it turns out that it was the zip function. In the past the lists that were zipped were reasonably short,...
11
9015
by: igor.tatarinov | last post by:
Given a bunch of arrays, if I want to create tuples, there is zip(arrays). What if I want to do the opposite: break a tuple up and append the values to given arrays: map(append, arrays, tupl)...
5
2642
n8kindt
by: n8kindt | last post by:
most areas on the east coast have zip codes starting with 0... you can probably see where i'm going with this already. i'm trying to relate these 2 databses: 1) TaxDB - an ODBC MySQL database...
1
1391
by: brandon | last post by:
I know this thread is old but I found a great website for inexpensive developer and marketing lists for zip codes. Plus they give free updates. http://www.listfactor.com They have lists for...
7
1060
by: moogyd | last post by:
Hi group, I have a basic question on the zip built in function. I am writing a simple text file comparison script, that compares line by line and character by character. The output is the...
0
1288
by: dontcare | last post by:
The Java version of extended VTD-XmL is released and available for download. This version supports 256 GB max file sizes and memory mapped capabilities. The updated documentation is also...
0
6908
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...
0
7048
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,...
1
6741
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...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
2997
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...
0
2986
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
183
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.