Tutor,

Good evening!    The goal is to parse a simple file and grab column one. 
Then print each value horizontally separated by a comma.
Why is Python adding a space padding between each value?   Please see below.
Thanks ahead of time.




INPUT_FILE # unwanted lines removed
################################
5555    [EMAIL PROTECTED]    blah    blah
1111    [EMAIL PROTECTED]    blah    blah
3333    [EMAIL PROTECTED]    blah    blah
4444    [EMAIL PROTECTED]    blah    blah


OUTPUT DESIRED
##################
5555,1111,3333,4444


SCRIPT
#########
import re

input_file = open('/tmp/file','r')
number_match = re.compile('^\d+\s+\w+\@')
for line in input_file.readlines():
        if number_match.match(line):
                line = re.split('\s+', line)
                print line[0],
                print ",",


OUTPUT GENERATED
####################
5555 , 1111 ,  3333 , 4444 ,       




_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to