Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
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…
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 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…

820 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