reading/writing files

Discussion in 'Python' started by sandipm, Nov 27, 2007.

  1. sandipm

    sandipm Guest

    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
     
    sandipm, Nov 27, 2007
    #1
    1. Advertising

  2. sandipm

    sandipm Guest

    f1= open("file1.pdf", "rb")
    x = f1.read()
    open("file2.pdf", "wb").write(x)



    works...

    thanks
    sandip

    On Nov 27, 5:43 pm, sandipm <> 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
     
    sandipm, Nov 27, 2007
    #2
    1. Advertising

  3. On Nov 27, 7:14 am, sandipm <> 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/
     
    BartlebyScrivener, Nov 27, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Modukuri
    Replies:
    0
    Views:
    2,936
    Modukuri
    May 19, 2004
  2. Daniel Gowans

    Reading/Writing pure binary files

    Daniel Gowans, May 27, 2004, in forum: VHDL
    Replies:
    2
    Views:
    5,260
  3. TC
    Replies:
    3
    Views:
    26,252
    jessica
    May 19, 2004
  4. Stephen
    Replies:
    1
    Views:
    679
    Kevin Spencer
    Mar 16, 2006
  5. Alex Polite
    Replies:
    17
    Views:
    759
    lyallex
    Jun 8, 2004
Loading...

Share This Page