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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:18:37+00:00 2026-06-04T18:18:37+00:00

I have the text file which contains 3 columns, first column having strings, second

  • 0

I have the text file which contains 3 columns, first column having strings, second column having integers and 3rd column having floating points like this:

steve   134     0.000010

Harry   133 0.000012

joanne  134 0.000022

steve   135 0.000024

joanne  133 0.000045

steve   133 0.000078

joanne  133 0.000079    

joanne  133 0.000081    

joanne  136 0.000083

steve   134 0.000085

steve   135 0.000087

I want output which looks like this:

steve   134(count=2,Time interval=0.000085-0.000010),133(count=1,Time interval=0.000078-0.000000),135(count=2,Time interval=0.000087-0.000024),136(count=0, Time interval=0.000000-0.000000)

harry   134(count=0, Time interval),133(count=1, Time interval),135(count=0, Time interval),136(count=0, Time interval)

joanne  134(count=1, Time interval),133(count=3, Time interval),135(count=0, Time interval),136(count=1, Time interval) 

[Time intervals of harry and joanne is calculated in the same way as that of steve].

Basically, if i take steve, i have to calculate how many entries of 133,134,135,136 each steve has and in what time interval did 133,134,135,136 happen. I hope you guys get my query.

  • 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-04T18:18:39+00:00Added an answer on June 4, 2026 at 6:18 pm

    This should get you started

    >>> from collections import defaultdict
    >>> names = defaultdict(list)
    >>> with open('f.txt') as f:
    ...    lines = [l.split() for l in f.readlines() if l.strip()]
    ...    for l in lines:
    ...      names[l[0]].append([l[1],l[2]])
    >>> for i in names.iteritems():
    ...    print i
    ... 
    ('steve', [['134', '0.000010'], ['135', '0.000024'], ['133', '0.000078'], ['134', 
    '0.000085'], ['135', '0.000087']])
    ('joanne', [['134', '0.000022'], ['133', '0.000045'], ['133', '0.000079'], ['133', '0.000081'], ['136', '0.000083']])
    ('Harry', [['133', '0.000012']])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file which contains columns of data that are either integer,
I have tab delim text file which contains the following columns: Probe A_sig A_Pval
I have a text file which contains data seperated by '|'. I need to
I have a text file which contains something like this: Hello, my name is
I have a simple text dictionary file, which contains words, separated by ';'.My problem
I have a text file which contains a long list of words. Some of
I have a text file which contains a time stamp on each line. My
I have to read a pdf file which contains a table with several columns.
I have a text file which contains: Cycle code Cycle month Cycle year Event
I have a text file which contains data I need to preload into a

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.