Sponsored Content
Full Discussion: problem in binning the data
Top Forums Shell Programming and Scripting problem in binning the data Post 302687969 by anurupa777 on Friday 17th of August 2012 09:43:20 AM
Old 08-17-2012
Data problem in binning the data

hi

i have some data like this
input:
Code:
1 apples oranges 234
2 oranges apples 2345
3 grapes bananas 1000000
4 melons banans 10000000
5 bananas apples 5000000
6 mangoes banans 2000000
7 apples bananas 1999999

i want to put all those which are coming between 1 and 999999 in to one bin (2nd bin would start from 1000000 to 1999999 and so on).
my output file should look like this
Code:
bin1_fruits
apples oranges 234
2 oranges apples 2345

Code:
bin2_fruits
grapes bananas 1000000
apples bananas 1999999

how to do this i am trying with perl and if needed i can post that here
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem of Data Loading....

i am studying a script which is used for data loading. it has functions which deletes all the existing data before loading and then loads new fresh data. but i am stuck up at function Replace into table ( col 1,col 2....) Does this signify All Inserts. (1 Reply)
Discussion started by: ankitgupta
1 Replies

2. Shell Programming and Scripting

Please help !!!!Problem with data file

I have a 1 million record file and in there i have 580 bad records meaning like they were spread on to 2 lines and is making my process fail as it is expecting single line records. How can i correct this records spread into 2 lines into single line or how i can writer these records into a new... (34 Replies)
Discussion started by: dsravan
34 Replies

3. Shell Programming and Scripting

Sampling and Binning- Engineering problem

Hi everyone! Can you please help me with some shell scripting? I have an input file input.txt It has 3 columns (Time, Event, Value) Time event Value 03:38:22 A 57 03:38:23 A 56 03:38:24 B 24 03:38:25 C 51 03:38:26 B 7 03:38:26 ... (7 Replies)
Discussion started by: Needhelp2
7 Replies

4. Shell Programming and Scripting

trimming and binning rows

I could not find this on the search.. I want to know how to trim a row so lets say I have a file that looks like this: bob 88888888888888 and I want to trim column 2 (lets say 4 off the front and end) bob 888888 Also, how would I bin column 2 Lets so I want to add and average... (1 Reply)
Discussion started by: phil_heath
1 Replies

5. Shell Programming and Scripting

Binning rows while skipping the first column

Hi I have a file that I want to bin. I am using this code: awk -F'\t' -v r=40 '{for(i=r;i<=NF;i+=r){for(j=0;j<r;j++){sum+=$(i-j)}printf "%s ", sum/r;sum=0}; printf "\n"}' file1 > file2 So basically what this code does is that it will averaging every 40 columns (creating bins of 40). But... (2 Replies)
Discussion started by: phil_heath
2 Replies

6. Shell Programming and Scripting

Data problem

Hi all, suppose i have one file and in that file there are thousand of record like below . if i want to fill the bold position below with some value suppose 000000 then how it would be in shell script ... (1 Reply)
Discussion started by: aishsimplesweet
1 Replies

7. Shell Programming and Scripting

Help to data re-arrangement problem

Input file <data id>="1">\ </data>\ <data id>="2">\ </data>\ <code>="1" target="2">\ </code>\ <data id>="1">\ </data>\ <data id>="2">\ </data>\ <code>="1" target="2">\ </code>\ <data id>="1">\ </data>\ <data id>="2">\ </data>\ <code>="1" target="2">\ </code>\ (2 Replies)
Discussion started by: cpp_beginner
2 Replies

8. Shell Programming and Scripting

Problem tabbing the data.

Hi All, I'm having a problem tabbing the data. can you please help me tab the data. i used sed but it's not working. ex. BUNDLE1MB(6spaces)|Y|ng_oliv10@shellscript.com.ph(6spaces)562.60.61.20(6spaces)562.61.35 here's my code sed "s/ //g" Userid_dsl_npm.txt__200 | sed "s/ |/ /g" |... (2 Replies)
Discussion started by: nikki1200
2 Replies

9. Shell Programming and Scripting

Gnuplot 3d binning

Hello I have a text file with tens of thousands of rows The format is x y where both x and y can be anything between -100 and +100. What I would like to do is have a 3d gnuplot where there are 10,000 squared or bins and each bin will count how many rows have a value that would be... (1 Reply)
Discussion started by: garethsays
1 Replies
Format(3pm)						User Contributed Perl Documentation					       Format(3pm)

NAME
String::Format - sprintf-like string formatting capabilities with arbitrary format definitions ABSTRACT
String::Format allows for sprintf-style formatting capabilities with arbitrary format definitions SYNOPSIS
use String::Format; my %fruit = ( 'a' => "apples", 'b' => "bannanas", 'g' => "grapefruits", 'm' => "melons", 'w' => "watermelons", ); my $format = "I like %a, %b, and %g, but not %m or %w."; print stringf($format, %fruit); # prints: # I like apples, bannanas, and grapefruits, but not melons or watermelons. DESCRIPTION
String::Format lets you define arbitrary printf-like format sequences to be expanded. This module would be most useful in configuration files and reporting tools, where the results of a query need to be formatted in a particular way. It was inspired by mutt's index_format and related directives (see <URL:http://www.mutt.org/doc/manual/manual-6.html#index_format>). FUNCTIONS
stringf String::Format exports a single function called stringf. stringf takes two arguments: a format string (see FORMAT STRINGS, below) and a reference to a hash of name => value pairs. These name => value pairs are what will be expanded in the format string. FORMAT STRINGS
Format strings must match the following regular expression: qr/ (% # leading '%' (-)? # left-align, rather than right (d*)? # (optional) minimum field width (?:.(d*))? # (optional) maximum field width ({.*?})? # (optional) stuff inside (S) # actual format character )/x; If the escape character specified does not exist in %args, then the original string is used. The alignment, minimum width, and maximum width options function identically to how they are defined in sprintf(3) (any variation is a bug, and should be reported). Note that Perl's sprintf definition is a little more liberal than the above regex; the deviations were intentional, and all deal with numeric formatting (the #, 0, and + leaders were specifically left out). The value attached to the key can be a scalar value or a subroutine reference; if it is a subroutine reference, then anything between the '{' and '}' ($5 in the above regex) will be passed as $_[0] to the subroutine reference. This allows for entries such as this: %args = ( d => sub { POSIX::strftime($_[0], localtime) }, ); Which can be invoked with this format string: "It is %{%M:%S}d right now, on %{%A, %B %e}d." And result in (for example): It is 17:45 right now, on Monday, February 4. Note that since the string is passed unmolested to the subroutine reference, and strftime would Do The Right Thing with this data, the above format string could be written as: "It is %{%M:%S right now, on %A, %B %e}d." By default, the formats 'n', 't', and '%' are defined to be a newline, tab, and '%', respectively, if they are not already defined in the hashref of arguments that gets passed it. So we can add carriage returns simply: "It is %{%M:%S right now, on %A, %B %e}d.%n" Because of how the string is parsed, the normal " " and " " are turned into two characters each, and are not treated as a newline and tab. This is a bug. FACTORY METHOD
String::Format also supports a class method, named stringfactory, which will return reference to a "primed" subroutine. stringfatory should be passed a reference to a hash of value; the returned subroutine will use these values as the %args hash. my $self = Some::Groovy::Package->new($$, $<, $^T); my %formats = ( 'i' => sub { $self->id }, 'd' => sub { $self->date }, 's' => sub { $self->subject }, 'b' => sub { $self->body }, ); my $index_format = String::Format->stringfactory(\%formats); print $index_format->($format1); print $index_format->($format2); This subroutine reference can be assigned to a local symbol table entry, and called normally, of course: *reformat = String::Format->stringfactory(\%formats); my $reformed = reformat($format_string); LICENSE
"String::Format" is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. AUTHOR
darren chamberlain <darren@cpan.org> perl v5.10.1 2009-05-17 Format(3pm)
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy