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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:38:11+00:00 2026-05-22T20:38:11+00:00

i have this input file 1.00 3 4 93.00 2 3 105.00 0 2

  • 0

i have this input file

     1.00 3 4
     93.00 2 3
     105.00 0 2
     119.00 0 2
     122.00 1 4
     202.00 1 3
     207.00 1 2
     210.00 1 4
     236.00 0 1
     237.00 0 4
     237.00 0 2
     240.00 1 3
     243.00 2 3
     243.00 3 4
     243.00 0 3
     275.00 0 4
     275.00 2 4
     353.00 0 3
     361.00 1 4
     411.00 0 1
     412.00 1 3
     425.00 0 3
     426.00 0 4
     455.00 1 4
     464.00 0 3
     520.00 0 4
     560.00 1 3
     561.00 1 4
     581.00 0 2

and i want to it be like this as the output

and compute this information

    field1 field2 nbrepeated time1 time2  time3   time4
    3      4      1          1.00  243.0  0       0
    2      3      1          93.0  243.0  0       0
    0      2      2          93.00 119.00 237.00  581.00 
    :      :      :          :     :      :       :
    :      :      :          :     :      :       :
    :      :      :          :     :      :       :




    <field1> <field2> <nbrepeated> <time1> <time2> <time3> <time4> are columns
  • 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-05-22T20:38:12+00:00Added an answer on May 22, 2026 at 8:38 pm

    A perl version:

    use strict;
    use warnings;
    
    my %data;
    while (my $line = <DATA>) {
        chomp($line);
        my @row = split(/\s/, $line);
        my $key = $row[1] . $row[2];
        push @{$data{$key}}, $row[0];
    }
    
    my $max = 0;
    for my $key (keys %data) {
        if (scalar @{$data{$key}} > $max) {
            $max = scalar @{$data{$key}};
        }
    }
    
    {
        my @times;
        push @times, "time" . $_ for (1 .. $max);
        myFormat("field1", "field2", "nbrepeated", @times);
    }
    
    for my $key (keys %data) {
        my ($f1, $f2) = split (//, $key);
        my $nr = $#{$data{$key}};
        my @times = @{$data{$key}};
        for (my $i = 0; $i < $max; $i++) {
            if (! defined $times[$i] ) {
                $times[$i] = 0;
            }
        }
        myFormat($f1, $f2, $nr, @times);
    }
    
    sub myFormat {
        printf "%-8s %-8s %-12s %-8s ", shift, shift, shift, shift;
        for my $line (@_) {
            printf "%-8s ", $line;
        }
        print "\n";
    }
    
    __DATA__
    1.00 3 4
    93.00 2 3
    105.00 0 2
    119.00 0 2
    122.00 1 4
    202.00 1 3
    207.00 1 2
    210.00 1 4
    236.00 0 1
    237.00 0 4
    237.00 0 2
    240.00 1 3
    243.00 2 3
    243.00 3 4
    243.00 0 3
    275.00 0 4
    275.00 2 4
    353.00 0 3
    361.00 1 4
    411.00 0 1
    412.00 1 3
    425.00 0 3
    426.00 0 4
    455.00 1 4
    464.00 0 3
    520.00 0 4
    560.00 1 3
    561.00 1 4
    581.00 0 2
    

    Produces the output:

    field1   field2   nbrepeated   time1    time2    time3    time4    time5
    0        1        1            236.00   411.00   0        0        0
    0        4        3            237.00   275.00   426.00   520.00   0
    1        2        0            207.00   0        0        0        0
    1        4        4            122.00   210.00   361.00   455.00   561.00
    0        2        3            105.00   119.00   237.00   581.00   0
    3        4        1            1.00     243.00   0        0        0
    0        3        3            243.00   353.00   425.00   464.00   0
    2        4        0            275.00   0        0        0        0
    2        3        1            93.00    243.00   0        0        0
    1        3        3            202.00   240.00   412.00   560.00   0
    

    The output is unsorted. Sorting it would be no problem, if you specify what way you want it sorted.

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

Sidebar

Related Questions

I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have this use case of an xml file with input like Input: <abc
I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I have created a JAR file in this way jar cf jar-file input-files .
I have a checkbox in my vm file like this : <input name=ISPOperatorList[0].ISPOperatorAccessStatus id=OPERATORAccessDeny0
Let's say for example I have this code: <input type=file id=file name=> <input class=uploadarea>
I have this input file (space is the separator for the two elements in
So basically, I have something like this - Input file with 2 integers. Code,
I have some problem with replace command. Input file i have this {a[$1]=a[$1]FS$2}END{for(i in
I have this code, which reads in input from a file and stores it

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.