473,385 Members | 2,162 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,385 software developers and data experts.

appending file

Kuo
Hi,
I'm trying to read a file (fileA) and append to another file(fileB).
However, I always get "^M" at the end. Does anyone know why ? Here is my
code ?

os.system("../syn/pin_assign.pl customer_netlist.txt")
shutil.copy("../fileB", "fileB")
ucf = open("fileB", "a")
pin = open("fileA", "r")
ucf.write(pin.read())
ucf.close;
pin.close;
sys.exit(0);

Here is what I get.

# FPGA CLOCK^M
NET "SYSCLK_A" loc = N16 | TNM_NET = SYSCLK_A;^M
NET "SYSCLK_AN" loc = M16 | TNM_NET = SYSCLK_A;^M
Note that if I don't do "ucf.write(pin.read())", everything is ok.

Thanks for any help.
Jun 29 '07 #1
3 1453
Kuo a écrit :
Hi,
I'm trying to read a file (fileA) and append to another file(fileB).
However, I always get "^M" at the end. Does anyone know why ? Here is my
code ?

os.system("../syn/pin_assign.pl customer_netlist.txt")
shutil.copy("../fileB", "fileB")
ucf = open("fileB", "a")
pin = open("fileA", "r")
ucf.write(pin.read())
ucf.close;
pin.close;
sys.exit(0);

Here is what I get.

# FPGA CLOCK^M
NET "SYSCLK_A" loc = N16 | TNM_NET = SYSCLK_A;^M
NET "SYSCLK_AN" loc = M16 | TNM_NET = SYSCLK_A;^M
Looks like a problem with newline format. Googling for "universal
newline" may be a good start.
Jun 29 '07 #2
On Friday 29 June 2007, Kuo wrote:
Hi,
I'm trying to read a file (fileA) and append to another file(fileB).
However, I always get "^M" at the end. Does anyone know why ? Here is my
code ?
I can't help you on your problem, but
ucf.close;
pin.close;
these statements don't do anything. You'll want

ucf.close()
pin.close()
sys.exit(0);

Here is what I get.

# FPGA CLOCK^M
NET "SYSCLK_A" loc = N16 | TNM_NET = SYSCLK_A;^M
NET "SYSCLK_AN" loc = M16 | TNM_NET = SYSCLK_A;^M
Note that if I don't do "ucf.write(pin.read())", everything is ok.

Thanks for any help.


--
Regards, Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu
Hacker key <http://hackerkey.com/>:
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBGhW7TJpinDvQhQ0sRAteYAJ4mL/r41f6YzLlOcjUNQHkZGzpbtgCfZ6+7
wXmCdnqtL0UR5gE4FNUddWk=
=Skye
-----END PGP SIGNATURE-----

Jun 29 '07 #3
On Jun 29, 1:04 pm, Kuo <chinchia....@sbcglobal.comwrote:
# FPGA CLOCK^M
NET "SYSCLK_A" loc = N16 | TNM_NET = SYSCLK_A;^M
NET "SYSCLK_AN" loc = M16 | TNM_NET = SYSCLK_A;^M
I see those bloody ^M's anytime I have to deal with a DOS file (since
it's the carrage return \r character). Is 'pin' a DOS generated file?
If you want to deal with a file which contains them, look for and get
rid of the \r character.

Jun 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Heller | last post by:
I want to append/insert additional data to an xml file. Context: I use gccxml to parse C header files. gccxml creates an xml file containing all the definitions from the header files. The xml...
1
by: dmiller23462 | last post by:
Hey guys.... I put an error-handling in my page and have it posted at the complete end of the code, see below(when people were putting in 's I was getting the delimiter errors). Great, I...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
1
by: Jonathan Taylor | last post by:
I have a large XML file, that is too large to read in to XmlDocument. I need to append data to this XML file without creating a new file, since I don't want to have two copies of the large file...
16
by: Michael | last post by:
I have a data application in a2k that I need to create two fixed width text files and then combine them to a single file The first file is header information and the second is transaction data. ...
2
by: tony.collings | last post by:
I started a thread here : http://groups.google.co.uk/group/microsoft.public.cmserver.general/browse_thread/thread/29d63077144004a9/c3888efdcb7338f6?hl=en#c3888efdcb7338f6 About creating an Email...
4
by: jasper | last post by:
How can this be done? Thanks
1
by: Frank | last post by:
Hi, Let's say I have a file named myFile.xml Within that file I have blocks of data which I'd like to add at different times during the day. e.g. <LogEntry>
2
by: sarada purkait | last post by:
hii i have to write into a file from the start and then go on appending to it .. i tried using ( ios::out|ios::app) but by this the file keeps on appending every time i run the program and the...
1
by: ofuuzo1 | last post by:
Hi, Is there anyway I can append a new element to an existing xml without first loading the existing file into a variable, adding the new element into the variable and saving it by overwriting the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.