473,605 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ 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 Unternehmensber atung
Führen durch präzise Daten
Jun 8 '06 #1
4 1676

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*******@gmai l.com> schrieb im Newsbeitrag
news:11******** *************@i 39g2000cwa.goog legroups.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
3325
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 way to change a zip() to a list comprehension. Should I just let those sleeping dogs lie? (list comprehensions seem more readable than map(), but if the list comprehension that does the equivalent of zip() is less expressive than zip(), I'll...
0
1794
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 General Mailing List For list archives: http://lists.mysql.com/mysql
1
4405
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 (Intel X86) Enterprise Edition on Windows NT 5.0 (Build 2195: ) Problem seems to be some extended procs that seemed to be running fine
18
1279
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, but once the size exceeded 10 million the zip function slowed to a crawl. Note that there was memory available to store over 100 million items. Now I know that zip () wastes lots of memory because it copies the content of the lists, I had used...
11
9036
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) except there is no unbound append() (List.append() does not exist, right?). Without append(), I am forced to write a (slow) explicit loop: for (a, v) in zip(arrays, tupl): a.append(v)
5
2655
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 (which is mainly used for our webstore) of every zip code and it lists all their tax info for city, county, and state. 2) CustomerDB - the database i have created and that we've been using for two months to store sales data and contact information...
1
1401
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 united states zip codes, cities, and counties. I needed the counties and found that there are ove 3000 in the united states! Didn't know that.
7
1065
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 original file, with an X in place of any characters that are different. I have managed a solution for a fixed (3) number of files, but I want a solution of any number of input files.
0
1300
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 available for download. In short, you can basically do full XPath query on documents that are bigger than memory space available on your machine.
0
8004
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
8425
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...
0
8418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8288
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
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
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 we have to send another system
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1271
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.