Solved

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

Posted on 2016-11-08
2
83 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python output problem 10 55
Python Regex Problem 24 156
How to find all the method available in a module in Python 1 106
Modify a small python script 19 129
"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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…

734 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