Solved

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

Posted on 2016-11-08
2
88 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Plenty of writing has gone on the web trying to compare Python with other competitive programming languages and vice versa. However, not much has been put into a wholistic perspective. This article should help you decide whether to adopt Python as a…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

688 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