Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk and sed script to create one output CSV file Post 303039398 by RudiC on Thursday 3rd of October 2019 05:32:06 AM
Old 10-03-2019
Please check your arithmetics for the SUM of pat9.
I can't see where you comply with the specified weight of .25.


Try
Code:
awk -F, -vOFS=, '
NR == 1 {
         $1 = sprintf ("%-25s", $1)
         gsub (/,/, "\t")
         print
         next
        }
        {printf "%-25s\t0", $1
         for (i=3; i<=NF; i++)  {WGT = ($i != $(i-1)) * .5
                                 printf "\t%s", WGT
                                 SUM[i] += WGT
                                }
         printf RS
        }
END     {printf "%-25s\t%s", "Sum of weights", 0
         for (i=3; i<=NF; i++) printf "\t%s", SUM[i]
         printf RS
        }
 ' file
PATTERN                         pat0    pat1    pat2    pat3    pat4    pat5    pat6    pat7    pat8    pat9
U_TOP_LOGIC/ipre_reg_0/Q        0       0       0.5     0       0.5     0       0.5     0       0.5     0
U_TOP_LOGIC/ipre_reg_6/Q        0       0       0.5     0       0.5     0       0.5     0       0.5     0
U_TOP_LOGIC/pre_reck_1/Q        0       0       0.5     0.5     0       0.5     0       0.5     0       0.5
U_TOP_LOGIC/pre_reg_10/Q        0       0.5     0.5     0.5     0       0.5     0       0.5     0       0
U_TOP_LOGIC/pre_reg_11/Q        0       0       0.5     0.5     0.5     0.5     0       0.5     0.5     0.5
Sum of weights                  0       0.5     2.5     1.5     1.5     1.5     1       1.5     1.5     1

Correction of eventual formatting deviances are left as an exercise to the gentle reader.
These 3 Users Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies

2. Shell Programming and Scripting

generating a create ddl from a csv file using awk

Hello, I would greatly appreciate some help on the this I have comma delimited file as follows: csv file -------- TEST1,fld1,VARCHAR2,3,,, TEST1,fld2,DATE,,,, TEST1,fld2,VARCHAR2,51,,, TEST1,fld4,VARCHAR2,2,,, TEST1,fld5,NUMBER,4,0,, TEST1,fld6,VARCHAR2,1,,,... (5 Replies)
Discussion started by: jville
5 Replies

3. Shell Programming and Scripting

Need help with a script to process a CSV file using SED and AWK

I get a CSV file every day with 2 columns and multiple rows ex: date1,date2 ( both the fields are varchar fields) This data has to be updated in a table which is being done manually and i want to automate that. 1. I have to select all the data from the prod table( 2 columns { date1,date2}) into... (4 Replies)
Discussion started by: kkb
4 Replies

4. Shell Programming and Scripting

how to create csv file using shell script

I have a file in multiple directory which has some records in the following format File: a/latest.txt , b/latest.txt, c/latest.txt -> Name=Jhon Age=27 Gender=M Street=LA Road Occupation=Service I want to generate a csv file from the above file as follows File: output.csv -> ... (9 Replies)
Discussion started by: rjk2504
9 Replies

5. Shell Programming and Scripting

Using awk/sed in handling csv file.

Please study the below script and the output Script: echo "Minimum ${host} ${process} response time=${min} ms" >> ${OUTDIR}/${OUTFILE}; echo "Maximum ${host} ${process} response time=${max} ms" >> ${OUTDIR}/${OUTFILE}; echo "Average ${host} ${process} response time=${avg} ms" >>... (0 Replies)
Discussion started by: ajincoep
0 Replies

6. Shell Programming and Scripting

awk/sed/something else for csv file

Hi, I have a filename.csv in which there are 3 colums, ie: Name ; prefixnumber ; number root ; 020 ; 1234567 user1,2,3 ; 070 ; 7654321 What I want is to merge colum 2 and 3 that it becomes 0201234567 or even better +31201234567 so the country number is used and drop the leading 0.... (9 Replies)
Discussion started by: necron
9 Replies

7. UNIX for Dummies Questions & Answers

Create csv with output filenames and file size

Hello All, Here is seeking a bit of help in trying to solve a problem. I am required to create a csv file as shown below: output.csv -> output_1,output_2,output_3,...,output_<N> filename1:20,filename2:30,filename3:30,...,filename<N>:30 by listing output_1, output_2,... , output<N> as... (3 Replies)
Discussion started by: vkumbhakarna
3 Replies

8. Shell Programming and Scripting

Script to create a CSV file

I created a script that will go out and so a "/sbin/chkconfig --list | egrep XXX" against a server list that would create an output file like the following example: ---------------------------------------------------------------------------------- SERVER1 RC_Script_1 0:off 1:off 2:off... (4 Replies)
Discussion started by: asnatlas
4 Replies

9. UNIX for Dummies Questions & Answers

How to Create excel file(.csv) using shell script?

Hi, i have shell script which compiles n number of test cases and execute them one by one. i want to create report in excel through script in which two columns namely "test id" and "release".second column have two subcolumns namely compiles and excutes. so i want first column should display test... (15 Replies)
Discussion started by: RamMore123
15 Replies

10. Shell Programming and Scripting

How to parse this file using awk and output in CSV format?

My source file looks like this: Cust-Number = "101" Cust-Name="Joe" Cust-Town="London" Cust-hobby="tennis" Cust-purchase="200" Cust-Number = "102" Cust-Name="Mary" Cust-Town="Newyork" Cust-hobby="reading" Cust-purchase="125" Now I want to parse this file (leaving out hobby) and... (10 Replies)
Discussion started by: Balav
10 Replies
CURLOPT_STREAM_WEIGHT(3)				     curl_easy_setopt options					  CURLOPT_STREAM_WEIGHT(3)

NAME
CURLOPT_STREAM_WEIGHT - set numerical stream weight SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_WEIGHT, long weight); DESCRIPTION
Set the long weight to a number between 1 and 256. When using HTTP/2, this option sets the individual weight for this particular stream used by the easy handle. Setting and using weights only makes sense and is only usable when doing multiple streams over the same connections, which thus implies that you use CURLMOPT_PIPE- LINING(3). This option can be set during transfer and will then cause the updated weight info get sent to the server the next time a HTTP/2 frame is sent to the server. See section 5.3 of RFC 7540 for protocol details: https://httpwg.github.io/specs/rfc7540.html#StreamPriority Streams with the same parent should be allocated resources proportionally based on their weight. So if you have two streams going, stream A with weight 16 and stream B with weight 32, stream B will get two thirds (32/48) of the available bandwidth (assuming the server can send off the data equally for both streams). DEFAULT
If nothing is set, the HTTP/2 protocol itself will use its own default which is 16. PROTOCOLS
HTTP/2 EXAMPLE
TODO AVAILABILITY
Added in 7.46.0 RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. SEE ALSO
CURLOPT_STREAM_DEPENDS(3), CURLOPT_STREAM_DEPENDS_E(3), CURLOPT_PIPEWAIT(3), CURLMOPT_PIPELINING(3), libcurl 7.54.0 February 03, 2016 CURLOPT_STREAM_WEIGHT(3)
All times are GMT -4. The time now is 10:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy