Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8421661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:12:33+00:00 2026-06-10T03:12:33+00:00

I stumbled across something that is not a problem, but something rather puzzling. I

  • 0

I stumbled across something that is not a problem, but something rather puzzling. I am copying a xml file myxml.xml to myxml_copy.xml and the file size of the output file is bigger. I don’t understand why this is so. Does this have anything to do with file encoding?

Anyway, the code I am using (although it is fairly trivial):

from xml.dom.minidom import parseString
import sys

def parseXml():
    data = open(in_filename,'r').read()
    return data


try:
    in_filename = sys.argv[1]
    out_filename = sys.argv[2]

    out_file = open(out_filename,'w')
    out_file.write(parseXml())
    out_file.close()
except Exception,e:
    print "usage: python copy.py <in_file> <out_file>"
    print "Error",e

NOTE: I am not looking for a way to copy a file. I will be modifying the original xml file later (cutting and pasting different parts of it).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:12:35+00:00Added an answer on June 10, 2026 at 3:12 am

    I think the problem is that the mode you open the file with needs to be rb and not just r and wb instead of w. (means – with binary mode)

    When it’s rb – strings like \r\n will stay this way, but when the mode is r – they will become \n.

    In short – just change the lines:

    data = open(in_filename,'r').read()
    out_file = open(out_filename,'w')
    

    to

    data = open(in_filename,'rb').read()
    out_file = open(out_filename,'wb')
    

    Did that help?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I'm not mistaken, I once stumbled across a product or something that let
I stumbled across a little problem with an ASP.NET Web Application. I got a
I stumbled across this problem in F#. Suppose, I want to declare two types
I recently stumbled across an article that claims Microsoft is banning the memcpy() function
I stumbled across something interesting and I cant put my finger why the behaviour
I am working my way through learning Twisted, and have stumbled across something I'm
I stumbled across something I can't figure out myself. I have an android project
When using objective-c there are many different ways you can stumble across something that
I've stumbled across a bit of problem when it comes to redirects behind a
I've stumbled across a really great project (CSS3 PIE) today that makes it possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.