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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:22:53+00:00 2026-06-15T14:22:53+00:00

I want to parse logfiles from rackspace. I’m using the official python sdk .

  • 0

I want to parse logfiles from rackspace. I’m using the official python sdk.
I have previously saved the file to disk and then read it from there with gzip.open.

Now I’m on heroku and can’t / don’t want to save the file to disk, but do the unzipping in memory.

However, I can’t manage to download the object as string or pseudo file object to handle it.

Does someone has an idea?

logString = ''
buffer = logfile.stream()

while True:
    try:
        logString += buffer.next()
    except StopIteration:
        break

# logString is always empty here

# I'd like to have something that enables me to do this:
for line in zlib.decompress(logString):
    # having each line of the log here

Update

I’ve noticed, that the empty string is not entirely true. This is going through a loop, and just the first occurence is empty. The next occurences I do have data (that looks like it’s gzipped), but I get this zlib error:

zlib.error: Error -3 while decompressing data: incorrect header check

Update II

As suggested, I implemented cStringIO, with the same result:

 buffer = logfile.stream()
     output = cStringIO.StringIO()

         while True:
             try:
                  output.write(buffer.next())
             except StopIteration:
             break

         print(output.getvalue())

Update III
This does work now:

output = cStringIO.StringIO()

try:
    for buffer in logfile.stream():
        output.write(buffer)
except StopIteration:
    break

And at least no crash in here, but it seems not to get actual lines:

for line in gzip.GzipFile(fileobj=output).readlines():
    # this is never reached

How to proceed here? Is there some easy way to see the incoming data as normal string to know if I’m on the right way?

  • 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-15T14:22:54+00:00Added an answer on June 15, 2026 at 2:22 pm

    I found out, that read() is also an option, that led to an easy solution like this:

     io = cStringIO.StringIO(logfile.read())
         for line in GzipFile(fileobj=io).readlines():
             impression = LogParser._parseLine(line)
             if impression is not None:
                 impressions.append(impression)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file in the drawable-folder. I want parse the XML-file using
I want to parse the xml file with dynamic content using DOM parser in
I want to parse a xml file using xquery in Ruby, I found this
I want to parse a dtd file and use the info I get from
i want parse xml file, which does't have xml extension, like this: http://bizonek.wrzuta.pl/xml/plik/1ANdXCgTOit/unknow/undefined/643/ my
I have a memory mapped file, from which I wish to parse the contents
I want to parse xml file in utf-8 and sort it by some field.
I have implemented ipad application in which i want parse table of content but
I want to parse with XmlSlurper a HTML document which I read using HTTPBuilder.
I want to parse a search string similar to that provided by Gmail using

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.