Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > reading/writing files

Reply
Thread Tools

reading/writing files

 
 
sandipm
Guest
Posts: n/a
 
      11-27-2007
Hi,

I am trying to read a file and write into other file. if I do it for
simple text file, it works well.
but for pdfs or some other mime types, its failing.

actually main problem is i am uploading file using cgi, in this
process I am getting content of file, and I am
trying to save the file. I think I need to specify mimetype of file
somehow..?
any quick solutions? or need to google.

sandip
 
Reply With Quote
 
 
 
 
sandipm
Guest
Posts: n/a
 
      11-27-2007
f1= open("file1.pdf", "rb")
x = f1.read()
open("file2.pdf", "wb").write(x)



works...

thanks
sandip

On Nov 27, 5:43 pm, sandipm <sandip.m...@gmail.com> wrote:
> Hi,
>
> I am trying to read a file and write into other file. if I do it for
> simple text file, it works well.
> but for pdfs or some other mime types, its failing.
>
> actually main problem is i am uploading file using cgi, in this
> process I am getting content of file, and I am
> trying to save the file. I think I need to specify mimetype of file
> somehow..?
> any quick solutions? or need to google.
>
> sandip


 
Reply With Quote
 
 
 
 
BartlebyScrivener
Guest
Posts: n/a
 
      11-27-2007
On Nov 27, 7:14 am, sandipm <sandip.m...@gmail.com> wrote:
> f1= open("file1.pdf", "rb")
> x = f1.read()
> open("file2.pdf", "wb").write(x)
>
> works...
>
> thanks
> sandip


You might also like:

http://pybrary.net/pyPdf/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check what symbols are defined in a .o files? .a files? and.so files in linux? yinglcs@gmail.com C++ 3 01-18-2009 05:23 PM
somebody know why every time what published it changes the namedlls and aspx files has link to its files. Alejandro Pombo ASP .Net 0 01-25-2006 01:54 PM
how i can extract text from the PDF files,power point files,Ms word files? crazyprakash Java 4 10-30-2005 10:17 AM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
Help! Files, Files, and more Files ... Everywhere JeffS Digital Photography 22 09-19-2004 01:47 AM



Advertisments