PDA

View Full Version : Is appending files is SAFE ?



baskar007
January 15th, 2010, 10:54 AM
Hi friends i have a small python scrip that will download a file in 5 parts, and append all files to a single file.

this codes are used to appending files.


partlist = ["part1",part2,part3] #part file paths
source = "Sourcefile.ext" #Source file
FF = open(source,"a")
for x in partlist:
F = open(x,"r")
data = F.read()
FF.write(data)
F.close()
FF.close()


is appending two or more files is safe?

Zugzwang
January 15th, 2010, 01:32 PM
What precisely do you mean by "safe"?

nvteighen
January 15th, 2010, 02:38 PM
Hi friends i have a small python scrip that will download a file in 5 parts, and append all files to a single file.

this codes are used to appending files.


partlist = ["part1",part2,part3] #part file paths
source = "Sourcefile.ext" #Source file
FF = open(source,"a")
for x in partlist:
F = open(x,"r")
data = F.read()
FF.write(data)
F.close()
FF.close()


is appending two or more files is safe?

If you mean safe in the sense of not losing data, it is as long as you don't do stupid things like moving the write cursor to the beginning and then write, e.g.

All these procedures are part of the Python core... Do you think Python would be so succesful if something as basic as opening a file in appending mode would fail? :p

lavinog
January 15th, 2010, 05:03 PM
Are these text or binary files?

baskar007
January 16th, 2010, 05:00 AM
What precisely do you mean by "safe"?
I mean losing datas

baskar007
January 16th, 2010, 05:03 AM
Are these text or binary files?
yeah all are binary files. like images,debs, videos (these code i auctually used in downloader application).

lostinxlation
January 18th, 2010, 02:02 AM
Deleted...

c0mput3r_n3rD
January 18th, 2010, 02:12 AM
Why not? appending is meant to put pieces of data together one after another on the next line.

phrostbyte
January 18th, 2010, 02:36 AM
It is as safe as it can be.

baskar007
January 18th, 2010, 06:14 AM
It is as safe as it can be.
Yeah ,Its safe there is no chance for corrupt. thanks for all who replyed.

phrostbyte
January 18th, 2010, 06:40 AM
Yeah ,Its safe there is no chance for corrupt. thanks for all who replyed.

There is always a chance for corruption, with any filesystem. :( Blame quantum mechanics.

lavinog
January 18th, 2010, 04:29 PM
There is always a chance for corruption, with any filesystem. :( Blame quantum mechanics.

Classical physics is good for corruption too.

c0mput3r_n3rD
January 18th, 2010, 06:07 PM
Hi friends i have a small python scrip that will download a file in 5 parts, and append all files to a single file.

this codes are used to appending files.


partlist = ["part1",part2,part3] #part file paths
source = "Sourcefile.ext" #Source file
FF = open(source,"a")
for x in partlist:
F = open(x,"r")
data = F.read()
FF.write(data)
F.close()
FF.close()
is appending two or more files is safe?

Easier way to open a file and appending data is just by simply writing


file = open("file_to_open.txt", "a")