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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:30:03+00:00 2026-06-18T13:30:03+00:00

I want to parse log file from below format, there are multiple urls are

  • 0

I want to parse log file from below format, there are multiple urls are repetitive and I want to compute total size of each and every urls as well as compute the size of particular type of urls, what would be the best way?

/images/img81a.jpg 6620
/images/img88a.jpg 6990
/images/img80b.jpg 5909 
/images/swb-30-furniture.gif 6216 
/images/button-arrow.png 498
/images/button-arrow-down.png 484 
/images/img81a.jpg 6620 
/images/img80b.jpg 5909 
/images/back-to-top_off.gif 1506 
/images/new-logo.gif 3377 
/images/img81a.jpg 6620        

Result:

Total size computation: 11503

All particular type of urls size computation:

 /images/img81a.jpg 19860
 /images/img80b.jpg 11818
 like wise ...

I append all size values to list and perform addition to get the total size result, but for similar kind of urls size computation requires two dimension dict, I guess. Which I am not about to create.

 a['/images/img81a.jpg'][6620] = 3
 a['/images/img88a.jpg'][6990] = 1
 a['/images/img80b.jpg'][5909] = 2
 like wise ...
  • 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-18T13:30:04+00:00Added an answer on June 18, 2026 at 1:30 pm

    Let’s say that you have all your lines in a list:

    with open('log.txt') as f:
        dico = dict()
        total_value = 0
        for line in f:
            #Feeding the dictionary
            split_array = line.split()
            possible_key = split_array[0]
            value = int(split_array[1])
    
            #If url has already been processed, update the value
            #Else, initialize the entry in the dictionary => default=0
            dico[possible_key] = dico.get(possible_key, default=0) + value
    
            #Updating the global sum
            total_value = total_value + value
    

    Usage:

    dico['/images/img81a.jpg'] => 19860
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i just want to parse two values from a html file . there will
I want to parse a timestamp from a log file that has been written
I want to parse data from a log file, pump it into a database,
I want to parse a XML file from a server on internet and save
I want to parse a log file (log.txt) which contains rows similar to these:
I want to parse an Apache access.log file with a python program in a
I want to parse the xml file with dynamic content using DOM parser in
I want to parse xml file in utf-8 and sort it by some field.
I want to parse a xml file using xquery in Ruby, I found this
I am using below code to send a file via blue-tooth from one device

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.