New Line occurring after text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Miguel Valenzue
    New Member
    • Dec 2010
    • 39

    New Line occurring after text

    I am outputting an xml list using join but a new line is appended to within the xml list. Not sure why.


    Code:
    for item in splitList:
        finalList.append (("<family_name>%s</family_name> <name>%s</name>") % (item[0], item[1]))
    
    f=open(outputFile, 'w')
    f.write("\n".join(finalList))
    f.close()
    output

    <family_name>Fa mily Name</family_name> <name>Facilitat or
    </name> ##This is on a new line! Don't want this
    <family_name>Br igham Young University</family_name> <name>Erica Williams
    </name>
    ...
  • Miguel Valenzue
    New Member
    • Dec 2010
    • 39

    #2
    SOLVED!
    I'm not sure how to erase questions but I solved this.
    the problem was not with the code I listed but with previous code when importing the file.

    I changed the code and redid the list this way.

    Code:
    for i in myList:
        splitList.append (i.rstrip('\n').split(';'))
    That stripped out the newline and it work. Case closed!

    Comment

    Working...