Sponsored Content
Top Forums Shell Programming and Scripting Interpolation of two values in two different files Post 302962828 by Don Cragun on Friday 18th of December 2015 09:32:40 PM
Old 12-18-2015
Now that we have a better understanding of the format of the data you're processing, we can throw away a bunch of code that was added to process mistaken assumptions. But, of course, you still haven't given us a clear description of the format of the data you are trying to process. The changed code below handles the additional idiosyncrasies you have now shown us, but we don't know that other parts of your day won't fail in a different way if it doesn't follow the format of the data you have shown us.

Try this:
Code:
awk '
BEGIN {	FS = DQ = "\""
	OFS=""
}

FNR == NR {
	if ($2 && ! /[{}:]/)
		T[FNR] = $2
	next
}

FNR in T {
	n = split ($2, N, ",")
	n = split (T[FNR], M, ",")
	$2 = DQ
	for(i = 1; i <= n; i++)
		$2 = $2 (N[i] + M[i]) / 2 (i < n ? ", " : DQ)
}

1
' FileA.txt FileB.txt

which produces output very similar to the format of your input files. With the data you provided in post #7 in this thread, it produces the output:
Code:
.... 
 	cell (AND2X1_RVT) {
			timing () {
 				related_pin : "A1";
 				timing_sense : "positive_unate";
 				cell_rise ("del_1_7_7") {
 					index_1("0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024");
 					index_2("0.1, 0.25, 0.5, 1, 2, 4, 8");
 					values("1.5, 3, 4.5, 6, 7.5, 9, 10.5", \
 					"12, 13.5, 15, 16.5, 18, 19.5, 21", \
 					"22.5, 24, 25.5, 27, 28, 30, 31.5", \
 					"33, 34.5, 36, 37.5, 39, 40.5, 42", \
 					"43.5, 45, 46.5, 48, 49.5, 51, 52.5", \
 					"54, 55.5, 57, 58.5, 60, 61.5, 63", \
 					"64.5, 66, 67.5, 69, 70.5, 72, 73.5");
 				}
 				rise_transition ("del_1_7_7") {
 					index_1("0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024");
 					index_2("0.1, 0.25, 0.5, 1, 2, 4, 8");
					values("75, 76.5, 78, 79.5, 81, 82.5, 84", \
 					"85.5, 87, 88.5, 90, 91.5, 93, 94.5", \
 					"96, 97.5, 99, 100.5, 102, 103.5, 105", \
 					"106.5, 108, 109.5, 111, 112.5, 114, 115.5", \
 					"117, 118.5, 120, 121.5, 123, 124.5, 126", \
 					"127.5, 129, 130.5, 132, 133.5, 135, 136.5", \
 					"138, 139.5, 141, 142.5, 144, 145.5, 147");
 				}
				cell_fall ("del_1_7_7") {
}

.....

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

variable interpolation

I've become obsessed with trying to get this to work. As of yet, I am unable to figure it out. Unfortunately, I don't have Linux or UNIX available when I get home. Anyone have tips for me on how I can pass param1 to ID via use of COUNTER and loop? thx. LIMIT=6 param1="999999999" export... (0 Replies)
Discussion started by: egkumpe
0 Replies

2. Shell Programming and Scripting

Cat Values from Several files if it meets criteria for column values

I have results from some statistical analyses. The format of the results are as given below: I want to select lines that have a p-value (last column) less than 0.05 from all the results files (*.results) and cat to a new results file. It would be very nice if a new column is added that tells... (2 Replies)
Discussion started by: genehunter
2 Replies

3. Shell Programming and Scripting

Interpolation using awk

Hi all, Consider I have a text file containing: 1003 60 1005 80 1100 110 Based on that file I need to create another file which is containing value from 1001 till 1100 which is a linear interpolation between two point (for 1004; 1006;1007 until 1109) and extrapolation based on 2... (7 Replies)
Discussion started by: ardy_yana
7 Replies

4. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

5. Shell Programming and Scripting

Hi ! whether it is possible to do interpolation in scripting...

Hi ! Experts... I just wanted to know whether it is possible in scripting...to do interpolation.... if so....have a look on my data file I need temperature and salinity value with a bin size of 0.5 m output looks somewhat like this dep temp sal 0.5 25 0.077 1 25 ... (12 Replies)
Discussion started by: nex_asp
12 Replies

6. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

7. Shell Programming and Scripting

Expand & Interpolation

Dear All, I have input like this, infile: 10 464310.16 20 464309.44 30 464309.02 40 464316.93 ... ... Desired output per step: out_step01: 10 464310.16 11 12 13 14 (9 Replies)
Discussion started by: attila
9 Replies

8. UNIX for Dummies Questions & Answers

Interpolation if there is no exact match for value

Dear all, could you help me with following question. There are two datasets (below). I need to find match between BP values from data1 and data2, and add corresponding CM value from data2 into data1. if there is not exact match, the corresponding CM value should be calculated using interpolation.... (20 Replies)
Discussion started by: kush
20 Replies

9. Shell Programming and Scripting

An interpolation between two files

Dear all, I always appreciate your help. I am an electrical engineer. I am using a tool for timing analysis of a circuit. I would like to interpolate results from two timing reports at different voltages (0.945V and 0.78V). If voltage is decreased, data arrival time is increased. For... (4 Replies)
Discussion started by: jypark22
4 Replies

10. UNIX for Beginners Questions & Answers

Replace Stub Values In One Group Of Files With Actual Values From Another Group Of Files

I have two directories of files (new-config-files and old-config-files): new-config-files/this-db/config.inc.php new-config-files/that-db/config.inc.php new-config-files/old-db/config.inc.php new-config-files/new-db/config.inc.php new-config-files/random-database/config.inc.php etc. ... (4 Replies)
Discussion started by: spacegoose
4 Replies
BLAZE-REMOVE(1) 					    BlazeBlogger Documentation						   BLAZE-REMOVE(1)

NAME
blaze-remove - removes a post or page from the BlazeBlogger repository SYNOPSIS
blaze-remove [-fipqPV] [-b directory] id... blaze-remove -h|-v DESCRIPTION
blaze-remove removes a blog post or a page with the specified id from the BlazeBlogger repository. OPTIONS
-b directory, --blogdir directory Allows you to specify a directory in which the BlazeBlogger repository is placed. The default option is a current working directory. -p, --page, --pages Tells blaze-remove to remove a page or pages. -P, --post, --posts Tells blaze-remove to remove a blog post or blog posts. This is the default option. -f, --force Disables requiring manual confirmation of each blog post or page removal. This is the default option. -i, --interactive Enables requiring manual confirmation of each blog post or page removal. -q, --quiet Disables displaying of unnecessary messages. -V, --verbose Enables displaying of all messages. This is the default option. -h, --help Displays usage information and exits. -v, --version Displays version information and exits. EXAMPLE USAGE
Remove a blog post: ~]$ blaze-remove 10 Successfully removed the post with ID 10. Remove a page: ~]$ blaze-remove -p 4 Successfully removed the page with ID 4. Remove multiple blog posts: ~]$ blaze-remove 10 4 6 Successfully removed the post with ID 10, 4 and 6. Remove multiple blog posts safely: ~]$ blaze-remove -i 10 4 6 Remove the post with ID 10 titled `Debian and Fedora Packages'? y Remove the post with ID 4 titled `BlazeBlogger 0.8.0 RC2'? y Remove the post with ID 6 titled `BlazeBlogger 0.8.1'? y Successfully removed the post with ID 10, 4 and 6. SEE ALSO
blaze-config(1), blaze-add(1), blaze-list(1) BUGS
To report a bug or to send a patch, please, add a new issue to the bug tracker at <http://code.google.com/p/blazeblogger/issues/>, or visit the discussion group at <http://groups.google.com/group/blazeblogger/>. COPYRIGHT
Copyright (C) 2008-2011 Jaromir Hradilek This program is free software; see the source for copying conditions. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Version 1.2.0 2012-03-05 BLAZE-REMOVE(1)
All times are GMT -4. The time now is 10:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy