Solved

Python2.7:I need a script to cut and separate in 2 parts this delimiter :

Posted on 2016-11-08
2
61 Views
Last Modified: 2016-11-11
Python2.7:I need a script to cut and separate in 2 parts this delimiter :
I have 3 Gb combo list so need something faster,thank you
example:
john:john
maddie:12345

would be

john
maddie

and

john
12345
0
Comment
Question by:john lambert
2 Comments
 
LVL 16

Accepted Solution

by:
Walter Ritzel earned 500 total points
ID: 41878575
The script would be very simple:

new_list = []
for item in list: # assuming that your 3gb combo is iterable 
   names = item.split(':')  # break on the : character
    new_list.append(names[0])  # add in a new list the name before the :
    new_list.append(names[1]) # add in a new list the name after the :

Open in new window


Now, can you explain a little more what you mean by a 3g combo list?
Are you parsing HTML? If you are using beautiful soup, the code above should work pretty well, just replace the list by the result of the findall method.
0
 

Author Closing Comment

by:john lambert
ID: 41884139
thank you...
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question