Solved

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

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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 …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now