473,396 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.


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]))
  3.  
  4. f=open(outputFile, 'w')
  5. f.write("\n".join(finalList))
  6. f.close()
  7.  
output

<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
</name>
...
Apr 25 '13 #1
1 1405
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.

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

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

Similar topics

0
by: Benjamin Rutt | last post by:
I have a tkinter 'Text' and 'Scrollbar' connected and working normally. When a new line of text is inserted (because I'm monitoring an output stream), I'd like the text and scrollbar to be...
1
by: Rocketman | last post by:
can i allign a line of text to the Top/bottom.
2
by: Martin Dew | last post by:
I have a RichTextBox called rtbOutput. I am adding lines of text using the AppendText method. What I want to do is immediately after adding this line of text make sure that this line of text is...
2
by: Tom | last post by:
I want to get the 'size' of a line of text so that I can set the width of a control to show all that text. For instance, say my text is 'The dog chased the cat around the room' and I want to set a...
4
by: Tor Inge Rislaa | last post by:
How add a line of text to a textfile? I need a way to open an existing file of type .txt insert a line of tekst and then close the file again. TIRislaa
3
by: GeorgeB | last post by:
How can I print a line of text to a dot matrix printer and just perform a linefeed then at another time (by another action) print again another line just below the line previously printed using...
3
by: japi | last post by:
Hi, i would like to know what approach i should use to insert (not append) a line of text to the begin of an existing text file. My current approach works, but i am afraid of loosing data if...
0
by: Nelu | last post by:
I would appreciate some comments on the code below for reading a line of text from a stream. #include <stdio.h> #include <stdlib.h> #include <stdint.h> /** * Reads a line of text from a...
2
by: Eric B. | last post by:
I coulda sworn it was possible to overwrite specific lines in a text file without disturbing the rest, or was that in C++? Will a TextWriter object do this? Eric B.
14
by: ziycon | last post by:
I have a function that takes a piece of text from the database and puts it into a textarea, I'm trying to put a symbol like '>' beside very line of text thats taken from the database and put into the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.