Sponsored Content
Top Forums Shell Programming and Scripting Compute value from more than three consecutive rows Post 302971123 by kathy wang on Friday 15th of April 2016 11:41:30 PM
Old 04-16-2016
Compute value from more than three consecutive rows

Hello all, I am working on a file like below:

Code:
site Date time value1 value2
0023 2014-01-01 00:00 32.0 23.7
0023 2014-01-01 01:00 38.0 29.9
0023 2014-01-01 02:00 85.0 26.6
0023 2014-01-01 03:00 34.0 25.3
0023 2014-01-01 04:00 37.0 23.8
0023 2014-01-01 05:00 80.0 20.3
0023 2014-01-01 06:00 90.0 20.0
0023 2014-01-01 07:00 180.0 20.0
0023 2014-01-01 08:00 30.0 20.0

The first column is site, second column is date (whole year of 2014), and third represent time (from 00:00 to 23:00 for each day), fourth and fifth columns are values. I need to compare column 4 and 5 based on the condition below:

For each site (column 1), if column 4 is more than 3 times of columns 5, and this pattern last for equal or more than 3 hours continually, plus the maximum of them must be higher than 100, print all the lines that meet the standard and count how many cases exist for each site. There are totally around 150 sites and each site has hourly data each day. Here is the output I want:

Code:
0023 2014-01-01 05:00 80.0 20.3 1
0023 2014-01-01 06:00 90.0 20.0 1
0023 2014-01-01 07:00 180.0 20.0 1
0023 2014-06-30 23:00 200.0 30.3 2
0023 2014-07-01 00:00 303.0 30.3 2
0023 2014-07-01 01:00 134.0 30.3 2
0025 2014-07-01 01:00 136.0 25.3 1           
0025 2014-07-01 02:00 116.0 25.3 1
0025 2014-07-01 03:00 106.0 25.3 1

Any help is highly appreciated!

Last edited by kathy wang; 04-18-2016 at 03:53 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compute total from a text file

Hi, I've encountered a problem with a perl and ksh script that totals a certain field in a text file. The computed total of the script is 295540304 but the expected is 297959288, a 2 million difference. The KSH script reads from bottom to top, and the discrepancy started on line 47 (1279th MAN... (1 Reply)
Discussion started by: rsf01
1 Replies

2. UNIX for Advanced & Expert Users

CPU Usage at another Compute Node?

Hi, I am trying to get the cpu usage of a job/process. The machine that has these jobs is a cluster with 1 master node and 10 compute nodes. Now, the complexity is that not all jobs are on the master node. So, in order to get the cpu usage of a job at another node, I have to ssh into it and... (0 Replies)
Discussion started by: davidfrank
0 Replies

3. Shell Programming and Scripting

How to capture 2 consecutive rows when a condition is true ?

Hi All, i have an input below. As long as "x= 1" , i would want to capture 2 lines using sed or awk for eg : 0001 x= 1 $---------------------------------..-.--.. 0001 tt= 137 171 423 1682 2826 0 Pls help. Thanks in advance. Note that the number of lines in each block do... (37 Replies)
Discussion started by: Raynon
37 Replies

4. Shell Programming and Scripting

to compute diskspace

Guys, have any idea for the script like this? also to compute w/ decimal. thanks a=10 b=20 c=30 d=40 if a < b then ( a -b)*1024 = free space b + (c -d) = total space if a > b then (b / d)*1024 = cpu (3 Replies)
Discussion started by: kenshinhimura
3 Replies

5. Shell Programming and Scripting

compute compilation time using script

Hi, I use this script to compute compilation time several time to get system performance and compare different system: #!/bin/sh # measure the different between time before and # after the compilation of benchmark # Start at iteration 1 num=1 while do # Add one to the iteration... (3 Replies)
Discussion started by: zainab
3 Replies

6. Web Development

How to compute previous and next buttons?

I have a project to migrate my club's membership database from Access to web based using MySQL/PHP, but I have a problem I can't get my head around and would appreciate some help... Background... I want to be able to display each member's data on screen and add a Previous and Next button to move... (2 Replies)
Discussion started by: JerryHone
2 Replies

7. Shell Programming and Scripting

remove consecutive duplicate rows

I have some data that looks like, 1 3300665.mol 3300665 5177008 102.093 2 3300665.mol 3300665 5177008 102.093 3 3294015.mol 3294015 5131552 102.114 4 3294015.mol 3294015 5131552 102.114 5 3293734.mol 3293734 5129625 104.152 6 3293734.mol ... (13 Replies)
Discussion started by: LMHmedchem
13 Replies

8. Shell Programming and Scripting

Compute Difference and Edit second, third columns

Hi Friends, My input file is like this chr1 100 200 chr1 300 330 chr1 2000 2000 chr1 5000 5000 chr2 7790 7890 chr2 8000 8000 If the difference of third and second columns is zero, then subtract 500 from second column and add 500 to the third column. So, my output would be chr1... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

9. Shell Programming and Scripting

Compute in milisecond by use of mktime

Hi, I want to calculate diff b/w these starttime and endtime with use of mktime. I need response time in milisecond. I am using mktime to get these times. last three digits are in milisecond Starttime 2013-04-03 08:54:19,989 End time 2013-04-03 08:54:39,389 (9 Replies)
Discussion started by: random_thoughts
9 Replies

10. UNIX for Beginners Questions & Answers

Forward Display from compute node

Hello, sorry if this is an easy thing, but I tried to make it run the whole morning, but it doesn't work so far... I am logged in on a visualization node of a high performance cluster. On this node I can run several gui-based software for the postprocessing of my cfd-data. As the... (1 Reply)
Discussion started by: Shlaeae
1 Replies
HPFTODIT(1)						      General Commands Manual						       HPFTODIT(1)

NAME
hpftodit - create font description files for use with groff -Tlj4 SYNOPSIS
hpftodit [ -adqsv ] [ -in ] tfm_file map_file font It is possible to have whitespace between the -i option and its parameter. DESCRIPTION
hpftodit creates a font file for use with a Hewlett-Packard LaserJet 4-series (or newer) printer with groff -Tlj4, using data from an HP tagged font metric (TFM) file. tfm_file is the name of the TFM file for the font; Intellifont and TrueType TFM files are supported, but symbol set TFM files are not. map_file is a file giving the groff names for characters in the font; this file should consist of a sequence of lines of the form: m u c1 c2 ... [ # comment ] where m is a decimal integer giving the MSL number of the character, u is a hexadecimal integer giving the Unicode value of the character, and c1, c2, ... are the groff names of the character. The values can be separated by any whitespace; the Unicode value must use uppercase digits A-F, and must be without a leading `0x', `u', or `U+'. Unicode values corresponding to composite glyphs are decomposed; e.g., `u00C0' becomes `u0041_0300'. The name for a glyph without a groff name may be given as uXXXX if the glyph corresponds to a Unicode value, or as an unnamed glyph `---'. If the given Unicode value is in the Private Use Area (0xE000-0xF8FF), the glyph is included as an unnamed glyph. Refer to groff_diff(1) for additional information about unnamed glyphs and how to access them. Blank lines and lines beginning with `#' are ignored. A `#' following one or more groff names begins a comment. Because `#' is a valid groff name, it must appear first in a list of groff names if a comment is included, e.g., 3 0023 # # number sign or 3 0023 # sh # number sign rather than 3 0023 sh # # number sign which will treat the first `#' as the beginning of the comment. font is the name of the groff font file. The groff font file is written to font; if font is specified as `-', the output is written to the standard output. The -s option should be given if the font is special (a font is special if troff should search it whenever a character is not found in the current font). If the font is special, it should be listed in the fonts command in the DESC file; if it is not special, there is no need to list it, since troff can automatically mount it when it's first used. If the -i option is used, hpftodit automatically will generate an italic correction, a left italic correction and a subscript correction for each character (the significance of these parameters is explained in groff_font(5)). OPTIONS
-a Include characters in the TFM file that are not included in the map file. A glyph with corresponding Unicode value is given the name uXXXX; a glyph without a Unicode value is included as an unnamed glyph `---'. A glyph with a Unicode value in the Private Use Area (0xE000-0xF8FF) also is included as an unnamed glyph. This option provides a simple means of adding Unicode-named and unnamed glyphs to a font without including them in the map file, but it affords little control over which glyphs are placed in a regular font and which are placed in a special font. The presence or absence of the -s option has some effect on which glyphs are included: without the -s option, only the "text" symbol sets are searched for matching glyphs; with the -s option, only the "mathematical" symbol sets are searched. Nonetheless, restricting the symbol sets searched isn't very selective--many glyphs are placed in both regular and special fonts. Normally, the -a option should be used only as a last resort. -d Dump information about the TFM file to the standard output; this option can be useful for ensuring that a TFM file is a proper match for a font, and that the contents of the TFM file are suitable. The information includes the values of important TFM tags, and a listing (by MSL number for Intellifont TFM files or by Unicode value for TrueType TFM files) of the glyphs included in the TFM file. The unit of measure `DU' for some tags indicates design units; there are 8782 design units per em for Intellifont fonts, and 2048 design units per em for TrueType fonts. Note that the accessibility of a glyph depends on its inclusion in a symbol set; some TFM files list many glyphs but only a few symbol sets. The glyph listing includes the glyph index within the TFM file, the MSL or Unicode value, and the symbol set and character code that will be used to print the glyph. If map_file is given, groff names are given for matching glyphs. If only the glyph index and MSL or Unicode value are given, the glyph does not appear in any supported symbol set and cannot be printed. With the -d option, map_file is optional, and font is ignored if given. -q Suppress warnings about characters in the map file that were not found in the TFM file. Warnings never are given for unnamed glyphs or by glyphs named by their Unicode values. This option is useful when sending the output of hpftodit to the standard output. -v Print the hpftodit version number. -s The font is special. This option adds the special command to the font file, and affects the order in which HP symbol sets are searched for each glyph. Without the -s option, the "text" sets are searched before the "mathematical" symbol sets. With the -s option, the search order is reversed. -in Generate an italic correction for each character so that the character's width plus the character's italic correction is equal to n thousandths of an em plus the amount by which the right edge of the character's bounding is to the right of the character's origin. If this would result in a negative italic correction, use a zero italic correction instead. Also generate a subscript correction equal to the product of the tangent of the slant of the font and four fifths of the x-height of the font. If this would result in a subscript correction greater than the italic correction, use a subscript correction equal to the italic correction instead. Also generate a left italic correction for each character equal to n thousandths of an em plus the amount by which the left edge of the character's bounding box is to the left of the character's origin. The left italic correction may be negative. This option normally is needed only with italic or oblique fonts; a value of 50 (0.05 em) usually is a reasonable choice. FILES
/usr/share/groff/1.19.2/font/devlj4/DESC Device description file. /usr/share/groff/1.19.2/font/devlj4/F Font description file for font F. /usr/share/groff/1.19.2/font/devlj4/generate/*.map Symbol mapping files SEE ALSO
groff(1), groff_diff(1), grolj4(1), groff_font(5), lj4_font(5) Groff Version 1.19.2 14 January 2004 HPFTODIT(1)
All times are GMT -4. The time now is 05:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy