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

  • Home
  • SEARCH
  • 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 9128491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:31:37+00:00 2026-06-17T07:31:37+00:00

I am making a search script for parsing log files in archives and am

  • 0

I am making a search script for parsing log files in archives and am stuck at one particular thing I didnt find resources anywhere else.

I need to somehow replace the “id1” of this string for “anything”. Simply put I want the script to take anything in that particular place in path. Is this possible only by using logZip as one huge regex?

logZip = ("c:/logs/" + str(id1) + "/" + str(id2) + "/" + str(id1) + "_log_" + str(dateID) + "_" + str(hourID) + "-00_" + str(id2) + ".zip")

As requested, Im adding a sample paths and files I want to define:

c:/logs/aaa1/sss2/aaa1_log_2013-01-14-13-00_sss2.zip
c:/logs/aaa2/sss2/aaa2_log_2013-01-14-13-00_sss2.zip
c:/logs/aaa3/sss2/aaa3_log_2013-01-14-13-00_sss2.zip

Next step will be to make the same thing with sss2 part.

  • 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-17T07:31:38+00:00Added an answer on June 17, 2026 at 7:31 am
    import glob
    import os
    
    id1 = '*'
    logZip = glob.glob(os.path.join("c:/logs", id1, id2, '{}_log_{}_{}-00_{}.zip'.format(id1, dateID, hourID, id2)))
    

    returns a list of complete paths to files where id1 is replaced by a wildcard *.

    os.path.join makes the path construction clearer.

    If logZip has to be a single file, you can use glob.iglob, which returns an iterator:

    id1 = '*'
    mask = os.path.join("c:/logs", id1, id2, '{}_log_{}_{}-00_{}.zip'.format(id1, dateID, hourID, id2))
    for logZip in glob.iglob(mask):
        # logZip is a single file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make search terms bold in this search script that I'm making.
I am making a search script and want to stop any deep level search
I have an AJAX search script I'm making and it gives results in real
I'm making a personal script to search google in another language and I've got
I'm trying to write a bash script that will recursively search a directory, find
I'm making a script parser in python and I'm a little stuck. I am
I am making a search query on local Apache Solr Server by browser and
I am using SQL Server 2000 and ASP.Net with c# for making a search
I'm making a simple search form in rails. In my search view I have
Ok, I attempted at making my own search function which doesnt work very well.

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.