By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,825 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,825 IT Pros & Developers. It's quick & easy.

New Line occurring after text

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

Expand|Select|Wrap|Line Numbers
  1. for item in splitList:
  2.     finalList.append (("<family_name>%s</family_name> <name>%s</name>") % (item[0], item[1]))
  4. f=open(outputFile, 'w')
  5. f.write("\n".join(finalList))
  6. f.close()

<family_name>Family Name</family_name> <name>Facilitator
</name> ##This is on a new line! Don't want this
<family_name>Brigham Young University</family_name> <name>Erica Williams
Apr 25 '13 #1
Share this Question
Share on Google+
1 Reply

P: 39
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.

Expand|Select|Wrap|Line Numbers
  2. for i in myList:
  3.     splitList.append (i.rstrip('\n').split(';'))
That stripped out the newline and it work. Case closed!
Apr 25 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.