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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:08:51+00:00 2026-06-01T03:08:51+00:00

I have lines in a log file, appended chronologically. For example, it could be

  • 0

I have lines in a log file, appended chronologically. For example, it could be data from the last 30 days, starting 30 days ago, then 29 days ago, then 28 days ago, etc.

I want to read the file in normal chronological order, but starting from a certain point (e.g., starting 7 days ago, read 7 days ago data, then 6 days ago data, then 5 days ago data, etc.)

One method is just reading the file normally, however for speed reasons I will need to:
– seek from the end of the file backward, exponentially, to find the right point to start at
– then, once I found the right point to start at, read lines one by one, in forward order

I’m having trouble getting this to work. I started by modifying the answer here:
Most efficient way to search the last x lines of a file in python

Can someone help, or provide guidance on a better way to do this?

  • 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-01T03:08:52+00:00Added an answer on June 1, 2026 at 3:08 am

    If speed is a concern, that probably means you are doing it many times, or have to do it on-the-fly. Thus, you could build an index file showing the position you have to seek to for each day, something like:

    Day 1: 0
    Day 2: 1048576
    Day 3: 2097152
    Day 4: 6291456
    ....
    

    This would allow fast lookup of any day once the index is built.

    The algorithm for updating this index would be to start at the position of the last known day, read forward, and each time you reach a new day add it to the index.

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

Sidebar

Related Questions

I've got log file, which I would like to have 60 lines in. When
I have a log file with the following lines: vi test.log 23 Jan 01:29:33.498/GLOBAL/ser:
I have a log file that has lines that look like this: 1,2546857-23541,f_last,user,4:19 P.M.,11/02/2009,START,27,27,3,c2546857-23541,
I have a log file which contains a number of error lines, such as:
I have a php file that prints the last 50 lines of a txt
I have a log file with lines like this: ...timestamp...(id=1234)..GO... ...timestamp...(id=1234)..DONE... Facts: timestamps are
Where I work we have a log file which contains lines like this: 31201007061308000000161639030001
I have some HUGE log files (50Mb; ~500K lines) I need to start filtering
Lets say I have 10 lines in a file. I have 2 parameters that
I'm developing a small C# application that scans a log file for lines containing

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.