Insert rows with computations of next row

Insert rows with computations of next row
# 8
11-25-2007
awk

Hi,

code:
 summer_cherry View Public Profile for summer_cherry Find all posts by summer_cherry
# 9
11-26-2007
It is closer but not right.

Thanks summer_cherry;
It is very closer, but I am not able to get the right answer using your script, either. Two time steps are missing in the output.
1987-01-01-22Z and 1987-01-01-23Z.
I think the script should have special care of midnight (00Z) in order to make 22Z and 23Z by subtracting 2 and 1, respectively.
For example,
2 hour time lag of 1987-02-01-00Z should be 1987-01-01-22Z, and
1 hour time lag of 1987-02-01-00Z should be 1987-01-01-23Z.

Jae
 Jae View Public Profile for Jae Find all posts by Jae
# 10
11-26-2007
It should be a challenge for you to figure it out yourself with the given answers.
Anyhow, I think I understand the problem.
I'm not able to test it out at this moment but try this:

Regards

Last edited by Franklin52; 11-26-2007 at 02:54 PM.. Reason: modified
 Franklin52 View Public Profile for Franklin52 Find all posts by Franklin52
# 11
11-26-2007
Here is the solution

FYI,
Based on previous scripts, I revised a little bit to make it work.
Again, thanks summer_cherry and Franklin.

awk 'BEGIN{format="%s-%02dz %12.6f"; n=0}
{
temp=substr(\$1,12,2)
t=substr(\$1,1,10)
if (temp=="00" && NR == 1)
{
vin=sprintf(format,t,temp,\$2)
out[n]=vin
n++
}
else if (temp=="00" && NR > 1)
{
num=\$2/3
vin=sprintf(format,t,22,num)
out[n]=vin
n++
vin=sprintf(format,t,23,num)
out[n]=vin
n++
vin=sprintf(format,t,temp,num)
out[n]=vin
n++
}
else
{
num=\$2/3
vin=sprintf(format,t,temp-2,num)
out[n]=vin
n++
vin=sprintf(format,t,temp-1,num)
out[n]=vin
n++
vin=sprintf(format,t,temp,num)
out[n]=vin
n++
}
}
END{
for (i=0;i<=n;i++)
print out[i]
}' inputfile
 Jae View Public Profile for Jae Find all posts by Jae
# 12
11-26-2007
With this solution you don't get the format as you requested, try my last script.

Regards
 Franklin52 View Public Profile for Franklin52 Find all posts by Franklin52

Test Your Knowledge in Computers #784
Difficulty: Easy
The firmware for the TRS-80 Model 100 was developed by Steve Jobs.
True or False?

Splitting single row into multiple rows based on for every 10 digits of last field of the row

Hi ALL, We have requirement in a file, i have multiple rows. Example below: Input file rows 01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212 01,1,102319,0,1,80,20,U,1,241,00000059420000006021 I need my output file should be as mentioned below. Last field should split for...

Insert row into empty file...how?

Greetings: I generate an empty flat file just fine when there's no data returned from my process, as the customer wants one always (using the 1st line of the below script). However, they also want at least the column names in this flat file (row 1, the only row to be in the emply file). I'm...

Print various rows in one row

I have this in a file 11.22.33.44 yyyyyyuser With awk/sed, I need this to be output as follows alias server.domain.com='ssh yyyyyyuser@11.22.33.44'

Insert rows with some rules??

Hi, I am rather new to Unix/Linus. I have this problem that I would like to solve using unix. Here is what I have start stop expression 1 5 15 2 6 10 I want a output like this position expression 1 15 2 25 3 ...

Converting rows to a single row

Hi all I have a file as below : Development System User Production i want to convert the file to below format: "Development","System","User","Production" Is it possible with UNIX ? if so can you please give me some direction on it ? Thanks, Satya Use code tags please, ty.

convert rows to single row

Hi I want to convert multiple rows ro single row ,I have tried with below one but I am not getting what I am expecting.Please any idea a.txt conn1=stg conn2=dev path=\xxx\a1.txt fre=a conn1=stg conn2=dev path=\xxx\a2.txt freq=a awk '/a/{ORS=" "}{print}END{print "\n"}'...

insert txt in the row

hi i am having text file like this 444 raju 666 ranga Clerk 999 rani officer 111 juhi i want to get the out put as 444 raju NA 666 ranga Clerk 999 rani officer 111 juhi NA pls help

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ...

9. UNIX for Dummies Questions & Answers

Hello, I am building an .xls file extracting info from a DB to be eventually emailed. All is good except how do I put in a header row.. like date, name of report etc. before the columns with the actual column name and data? Thanks for any assistance.. the below is after I have signed into...

Concatenate 2 rows into 1 row

I need to search a file for two values (valueA & valueB). ValueA will be on a different row than valueB, and concatenate the two together on the same row of my output. Example: search input file for strings "node" and "OS", combine the two results into one row input node A text text OS...