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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:53:59+00:00 2026-06-07T19:53:59+00:00

Here is the contents of my .log file Current Date & Time, Trans, Elapsed

  • 0

Here is the contents of my .log file

Current Date & Time, Trans, Elapsed Time, Response Time, Trans
Rate,

Wed Jul 18 10:03:1, 5, 0.37 sec, 0.00 sec, 13.51 t/s,

Wed Jul 18 10:03:5, 5, 0.45 sec, 0.00 sec, 11.11 t/s,

Wed Jul 18 10:04:0, 5, 0.91 sec, 0.00 sec, 5.49 t/s,

Wed Jul 18 10:22:4, 12, 0.79 sec, 0.00 sec, 15.19 t/s,

Wed Jul 18 10:23:0, 12, 0.56 sec, 0.00 sec, 21.43 t/s,

Wed Jul 18 10:23:1, 12, 0.53 sec, 0.00 sec, 22.64 t/s,

I want to put these values directly into a 2D list in python, but every solution I have found just creates a list item for each row. I want the value of a list slot to be one comma separated value. EG row 3 column 2 in the list would store 5. It’s probably quite simple but I’ve been searching and searching and found nothing to do it this way. Any help much appreciated. Cheers.

Update:

Traceback (most recent call last):
File “StressTestCompare.py”, line 45, in
print data[2][0]
IndexError: list index out of range

[[‘Current Date & Time’, ‘\tTrans’, ‘\tElapsed Time’, ‘\tResponse Time’, ‘\tTrans Rate’, ‘\tThroughput’, ‘\tConc’, ‘\tOKAY’, ‘\tFailed’, ‘\tData Transfer’, ‘\tIP Address’, ”], [‘Wed Jul 18 10:03:1’, ‘\t5’, ‘\t0.37 sec’, ‘\t0.00 sec’, ‘\t13.51 t/s’, ‘\t0.00 b/s’, ‘\t0.00’, ‘\t0’, ‘\t0’, ‘\t0 bytes’, ‘\t10.2.2.55:8080’], [], [‘Wed Jul 18 10:03:5’, ‘\t5’, ‘\t0.45 sec’, ‘\t0.00 sec’, ‘\t11.11 t/s’, ‘\t0.00 b/s’, ‘\t0.00’, ‘\t0’, ‘\t5’, ‘\t0 bytes’, ‘\t10.2.2.56:8080’], [], [‘Wed Jul 18 10:04:0’, ‘\t5’, ‘\t0.91 sec’, ‘\t0.00 sec’, ‘\t5.49 t/s’, ‘\t1609.89 b/s’, ‘\t0.00’, ‘\t5’, ‘\t0’, ‘\t1465 bytes’, ‘\t10.2.2.57:8080’], [], [‘Wed Jul 18 10:22:4’, ‘\t12’, ‘\t0.79 sec’, ‘\t0.00 sec’, ‘\t15.19 t/s’, ‘\t0.00 b/s’, ‘\t0.00’, ‘\t0’, ‘\t0’, ‘\t0 bytes’, ‘\t10.2.2.55:8080’], [], [‘Wed Jul 18 10:23:0’, ‘\t12’, ‘\t0.56 sec’, ‘\t0.00 sec’, ‘\t21.43 t/s’, ‘\t0.00 b/s’, ‘\t0.00’, ‘\t0’, ‘\t12’, ‘\t0 bytes’, ‘\t10.2.2.56:8080’], [], [‘Wed Jul 18 10:23:1’, ‘\t12’, ‘\t0.53 sec’, ‘\t0.00 sec’, ‘\t22.64 t/s’, ‘\t0.00 b/s’, ‘\t0.00’, ‘\t0’, ‘\t0’, ‘\t0 bytes’, ‘\t10.2.2.57:8080’], []]

Using print repr(data) It comes out like this, is it possible to get it in an easier to read format? Even still it looks like it’s all there from what I can see, so I don’t know why i’m getting the out of range error.

  • 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-07T19:54:01+00:00Added an answer on June 7, 2026 at 7:54 pm

    The csv module comes in handy for this:

    import csv
    
    with open('data.txt', 'rb') as inf:
         data = list(csv.reader(inf, skipinitialspace=True))
         data = [i for i in data if i] ## add to deal w/ blank lines in data file
    

    would give you variable data with contents:

    [['Current Date & Time',
      'Trans',
      'Elapsed Time',
      'Response Time',
      'Trans Rate',
      ''],
     ['Wed Jul 18 10:03:1', '5', '0.37 sec', '0.00 sec', '13.51 t/s', ''],
     ['Wed Jul 18 10:03:5', '5', '0.45 sec', '0.00 sec', '11.11 t/s', ''],
     ['Wed Jul 18 10:04:0', '5', '0.91 sec', '0.00 sec', '5.49 t/s', ''],
     ['Wed Jul 18 10:22:4', '12', '0.79 sec', '0.00 sec', '15.19 t/s', ''],
     ['Wed Jul 18 10:23:0', '12', '0.56 sec', '0.00 sec', '21.43 t/s', ''],
     ['Wed Jul 18 10:23:1', '12', '0.53 sec', '0.00 sec', '22.64 t/s', '']]
    

    and data[2][1] (not data[3][2] due to zero-based indexing) would give you

    '5'
    

    a string, which you could convert to an integer 5 with int(data[2][1])

    Update:

    Added data = [i for i in data if i] to deal with possible blank lines in input causing problems in OP’s updated post.

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

Sidebar

Related Questions

Here is the entire contents of the file: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8>
I'm reading a log file which has following contents DateTime: 2012-12-09 17:00:18 Command: ALTER
I need to parse a Weblogic log file with ANTLR. Here is the example:
Since some time I'm having problems with Eclipse. When opening any file with a
I need to print out the contents of an xml file into some txt
I put an .htaccess file in my webroot with the following contents RewriteBase /
Here is what I've done: Create folder testA Create a file a.txt with it's
I can successfully parse the contents of a JSON file, using the JSON-Framework 3.0,
I'm trying to retrieve image file from my local server. Here is my (very
I need to write to a particular log file, and append the results of

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.