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 6336447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:03:31+00:00 2026-05-24T19:03:31+00:00

I opened an 8 MB file in Python, because I wanted to batch change various

  • 0

I opened an 8 MB file in Python, because I wanted to batch change various types of file names. I went through and loaded the file into a string and used the string method replace to replace everything. I then noticed that only half of the file was being replaced; as if Python wasn’t fully opening the file.

Is there some kind of string size limit or max file size limit that I must play within the bounds of in Python?

Refer to the code in Python search and replace not replacing properly.

I have changed to the suggested code. The buffer is an 8 MB HTML file that is over 150k lines. The replacement code works perfectly; it’s just that it’s not replacing everything. Or for example one error that is a pain is:

When I’m attempting to replace the string ff10 to FF-10, it’ll be changed to FF-010.

  • 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-05-24T19:03:32+00:00Added an answer on May 24, 2026 at 7:03 pm

    No, there is no reachable maximum on the size of a file Python can open. 8 MB is tiny in modern terms. You made a mistake somewhere.

    People regularly load gigabytes of data into memory. Depending on your computer’s RAM, whether it’s 64- or 32- bit OS and processor, the practical maximum for you may be anywhere from 1 GB up before you get a MemoryError.

    As a test, I just loaded a 350 MB file into a string. It took only a few seconds. I then wrote it back out to a file. That took a little longer. I then hashed the file. The two are identical.

    Python has no problems with large strings, until you hit the limit of your RAM, operating system, or processor.

    You say you “went through and loaded the file into a string” — that sounds like the first place you could have made a mistake. To load a file into a string, you just do fileobject.read(). If you did it some other way, that could be the problem.

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

Sidebar

Related Questions

let's say I opened a file, then parsed it into lines. Then I use
Recently I opened a .dll file produced by Visual Studio 9 while compiling a
I opened a domain in Plesk and wanted to give the user access to
I have opened an HTML file using file_get_contents('http://www.example.com/file.html') and want to parse the line
If a file is opened using the following command: FILE *f1=fopen(test.dat,a+); The man page
I opened hello.cpp. Why isn't there File -> Compile -> hello.cpp? What is an
I opened a javaScript file in a javaScript time.... document.write(<script src='newnote.js' type='text/javascript'></script>); is there
Say we have opened a text file. Is it possible to define a pointer
I have opened a file with blast results and printed out the hits in
In firefox I have opened a locally stored file with the file:// protocol (file:///c:/temp/foo.html)

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.