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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:05:15+00:00 2026-05-11T18:05:15+00:00

I do have to deal with very large plain text files (over 10 gigabytes,

  • 0

I do have to deal with very large plain text files (over 10 gigabytes, yeah I know it depends what we should call large), with very long lines.

My most recent task involves some line editing based on data from another file.

The data file (which should be modified) contains 1500000 lines, each of them are e.g. 800 chars long. Each line is unique, and contains only one identity number, each identity number is unique)

The modifier file is e.g. 1800 lines long, contains an identity number, and an amount and a date which should be modified in the data file.

I just transformed (with Vim regex) the modifier file to sed, but it’s very inefficient.

Let’s say I have a line like this in the data file:

(some 500 character)id_number(some 300 character)

And I need to modify data in the 300 char part.

Based on the modifier file, I come up with sed lines like this:

/id_number/ s/^\(.\{650\}\).\{20\}/\1CHANGED_AMOUNT_AND_DATA/

So I have 1800 lines like this.

But I know, that even on a very fast server, if I do a

sed -i.bak -f modifier.sed data.file

It’s very slow, because it has to read every pattern x every line.

Isn’t there a better way?

Note: I’m not a programmer, had never learnt (in school) about algorithms.
I can use awk, sed, an outdated version of perl on the server.

  • 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-11T18:05:15+00:00Added an answer on May 11, 2026 at 6:05 pm

    My suggested approaches (in order of desirably) would be to process this data as:

    1. A database (even a simple SQLite-based DB with an index will perform much better than sed/awk on a 10GB file)
    2. A flat file containing fixed record lengths
    3. A flat file containing variable record lengths

    Using a database takes care of all those little details that slow down text-file processing (finding the record you care about, modifying the data, storing it back to the DB). Take a look for DBD::SQLite in the case of Perl.

    If you want to stick with flat files, you’ll want to maintain an index manually alongside the big file so you can more easily look up the record numbers you’ll need to manipulate. Or, better yet, perhaps your ID numbers are your record numbers?

    If you have variable record lengths, I’d suggest converting to fixed-record lengths (since it appears only your ID is variable length). If you can’t do that, perhaps any existing data will not ever move around in the file? Then you can maintain that previously mentioned index and add new entries as necessary, with the difference is that instead of the index pointing to record number, you now point to the absolute position in the file.

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

Sidebar

Related Questions

I have to deal with very large text files (2 GBs), it is mandatory
I have very large text files that has the format below: items=item1|item2|item3|item4&ids=18|117|34|315&locations=5|26|9|12#Characteristic_1#Describe Characteristic_1#http://example.com items=item1|item2|item3|item4&ids=18|117|34|315&locations=5|26|9|12#Characteristic_2#Describe
I am trying to deal with a very large dataset. I have k =
We have a very large Java Swing desktop application comprising of a great deal
Why has MS decided to use convention over configuration. I deal with very large
I've been trying to deal with some delimited text files that have non standard
I am using java and have to deal with numbers larger than long (which
I have 16 large xml files. When I say Large, I am talking in
First, I have a very large cvs repository and I'm trying to switch things
Here is a hypotetical scenario. I have very large number of user names (say

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.