Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Pivoting data based on a header field Post 303032441 by saj on Monday 18th of March 2019 10:36:42 AM
Old 03-18-2019
Pivoting data based on a header field

Hi Team,

Could you please help me with the below scenario.

I have a file which is in the below format.

Code:
Zipcode,001,001f,002,002f,003,003f,004,004f,005,005f,006,006f,007,007f
0050, ,0, ,0, ,0, ,1,*,7, ,7, ,7
0060, ,0, ,0, ,7, ,0,*,7, ,0, ,0

Would need the output as below.
First field will be repeating for the values.
Header value need to be pivoted as second field, and corresponding header values in the third field.

Code:
005,001,0
005,001f,	
005,002,0
005,002f,	
005,003,0
005,003f,	
005,004,1
005,004f,*	
005,005,7
005,005f,0
005,006,7
005,006f,	
006,001,0
006,001f,	
006,002,0
006,002f,	
006,003,0
006,003f,	
006,004,0
006,004f,	
006,005,0
006,005f,0
006,006,7
006,006f,

Please provide your valuable inputs.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

generating reports based on time field of network data

hi i have data extracted in the following format ranging around 300000 to 800000 records in a text file , the format is of network data . No. Time Source Destination Protocol 1 1998-06-05 17:20:23.569905 HP_61:aa:c9 HP_61:aa:c9 ... (1 Reply)
Discussion started by: renukaprasadb
1 Replies

2. Shell Programming and Scripting

extract data in a csv file based on a certain field.

I have a csv file that I need to extract some data from depending on another field after reading info from another text file. The text file would say have 592560 in it. The csv file may have some data like so Field 1 Field2 Field3 Field4 Field5 Field6 20009756 1 ... (9 Replies)
Discussion started by: GroveTuckey
9 Replies

3. UNIX for Dummies Questions & Answers

Sorting data in file based on field in another file

Hi, I have two files, one of which I would like to sort based on the order of the data in the second. I would like to do this using a simple unix statement. My two files as follows: File 1: 12345 1 2 2 2 0 0 12349 0 0 2 2 1 2 12350 1 2 1 2 2 2 . . . File2: 12350... (3 Replies)
Discussion started by: kasan0
3 Replies

4. Shell Programming and Scripting

Matching and Merging csv data fields based on a common field

Dear List, I have a file of csv data which has a different line per compliance check per host. I do not want any omissions from this csv data file which looks like this: date,hostname,status,color,check 02-03-2012,COMP1,FAIL,Yellow,auth_pass_change... (3 Replies)
Discussion started by: landossa
3 Replies

5. Shell Programming and Scripting

Pivoting the data

Hello Unix guys, I have the following 4 column data, which is a output of db2 select query: Need to pivot the data. sample Input: Year Month Country Counts 2012 Aug Canada 114 2012 Aug USA 92 2012 Aug Mexico 3 2012 Aug ... (3 Replies)
Discussion started by: karumudi7
3 Replies

6. Shell Programming and Scripting

awk : Filter a set of data to parse header line and last field of multiple same match.

Hi Experts, I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output file: ############################################################################################### PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Discussion started by: rveri
5 Replies

7. Shell Programming and Scripting

Pivoting csv field from pipe delimited file

Hello All, Thanks for taking time to read through the thread and for providing any possible solution. I am trying to pivot a comma separated field in a pipe delimited file. Data looks something like this: Field1|Field2 123|345,567,789 234|563,560 345|975,098,985,397,984 456|736 Desired... (8 Replies)
Discussion started by: svks1985
8 Replies

8. Linux

Pivoting data with awk

Hi Friends, I need to pivot data . Below is my source data Source Data PK PRTY_KEY_ID PRTY_SUB_KEY_ID KEY_COL_VAL_TX MTCH_CNFDNCE_RATE 007824822 428844791 1 #Jemmy#Pom#600 Kearsarge Way 100 007824822 429283974 1 #Jemmy#Pom#120 Broadway 100 007824822 429739103 1 #Jemmy#Pom#600 Keae Way#757... (0 Replies)
Discussion started by: patiljeevan3
0 Replies

9. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
CheckDigits(3pm)					User Contributed Perl Documentation					  CheckDigits(3pm)

NAME
Algorithm::CheckDigits - Perl extension to generate and test check digits SYNOPSIS
perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods or use Algorithm::CheckDigits; @ml = Algorithm::CheckDigits->method_list(); $isbn = CheckDigits('ISBN'); if ($isbn->is_valid('3-930673-48-7')) { # do something } $cn = $isbn->complete('3-930673-48'); # $cn = '3-930673-48-7' $cd = $isbn->checkdigit('3-930673-48-7'); # $cd = '7' $bn = $isbn->basenumber('3-930673-48-7'); # $bn = '3-930673-48' ABSTRACT
This module provides a number of methods to test and generate check digits. For more information have a look at the web site www.pruefziffernberechnung.de (german). SUBROUTINES
/METHODS CheckDigits($method) Returns an object of an appropriate Algorithm::CheckDigits class for the given algorithm. Dies with an error message if called with an unknown algorithm. See below for the available algorithms. Every object understands the following methods: is_valid($number) Returns true or false if $number contains/contains no valid check digit. complete($number) Returns a string representation of $number completed with the appropriate check digit. checkdigit($number) Extracts the check digit from $number if $number contains a valid check digit. basenumber($number) Extracts the basenumber from $number if $number contains a valid check digit. Algorithm::CheckDigits::method_list() Returns a list of known methods for check digit computation. Algorithm::CheckDigits::print_methods() Returns a list of known methods for check digit computation. You may use the following to find out which methods your version of Algorithm::CheckDigits provides and where to look for further information. perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods CHECK SUM METHODS At the moment these methods to compute check digits are provided: (vatrn - VAT Return Number, in german ustid UmsatzSTeuer-ID) m07-001 See Algorithm::CheckDigits::M07_001. euronote, m09-001 European bank notes, see Algorithm::CheckDigits::M09_001. amex, bahncard, diners, discover, enroute, eurocard, happydigits, isin, jcb, klubkarstadt, mastercard, miles&more, visa, m09-001, imei, imeisv See Algorithm::CheckDigits::M10_001. siren, siret, m10-002 See Algorithm::CheckDigits::M10_002. ismn, m10-003 See Algorithm::CheckDigits::M10_003. ean, iln, isbn13, nve, 2aus5, m10-004 See Algorithm::CheckDigits::M10_004. identcode_dp, leitcode_dp, m10-005 See Algorithm::CheckDigits::M10_005. rentenversicherung, m10-006 See Algorithm::CheckDigits::M10_006. sedol, m10-008 See Algorithm::CheckDigits::M10_008. betriebsnummer, m10-009 See Algorithm::CheckDigits::M10_009. postscheckkonti, m10-010 See Algorithm::CheckDigits::M10_010. ups, m10-011 See Algorithm::CheckDigits::M10_011. hkid, isbn, issn, nhs_gb, ustid_pt, vat_sl, wagonnr_br, m11-001 See Algorithm::CheckDigits::M11_001. pzn, m11-002 See Algorithm::CheckDigits::M11_002. pkz, m11-003 See Algorithm::CheckDigits::M11_003. cpf, titulo_eleitor, m11-004 See Algorithm::CheckDigits::M11_004. ccc_es, m11-006 See Algorithm::CheckDigits::M11_006. ustid_fi, vatrn_fi, m11-007 See Algorithm::CheckDigits::M11_007. ustid_dk, vatrn_dk, m11-008 See Algorithm::CheckDigits::M11_008. nric_sg, m11-009 See Algorithm::CheckDigits::M11_009. ahv_ch, m11-010 See Algorithm::CheckDigits::M11_010. ustid_nl, vatrn_nl, m11-011 See Algorithm::CheckDigits::M11_011. bwpk_de, m11-012 See Algorithm::CheckDigits::M11_012. ustid_gr, vatrn_gr, m11-013 See Algorithm::CheckDigits::M11_013. esr5_ch, m11-015 See Algorithm::CheckDigits::M11_015. ustid_pl, vatrn_pl, m11-016 See Algorithm::CheckDigits::M11_016. ecno, ec-no, einecs, elincs, m11-017 See Algorithm::CheckDigits::M11_017. isan, m16-001 See Algorithm::CheckDigits::M16_001. dni_es, m23-001 See Algorithm::CheckDigits::M23_001. ustid_ie, vatrn_ie, m23-002 See Algorithm::CheckDigits::M23_002. code_39, m43-001 See Algorithm::CheckDigits::M43_001. ustid_lu, vatrn_lu, m89-001 See Algorithm::CheckDigits::M89_001. ustid_be, vatrn_be, m97-001 See Algorithm::CheckDigits::M97_001. iban, m97-002 See Algorithm::CheckDigits::M97_002. upc, mbase-001 See Algorithm::CheckDigits::MBase_001. blutbeutel, bzue_de, ustid_de, vatrn_de, mbase-002 See Algorithm::CheckDigits::MBase_002. sici, mbase-003 See Algorithm::CheckDigits::MBase_003. pa_de, mxx-001 See Algorithm::CheckDigits::MXX_001. cas, mxx-002 See Algorithm::CheckDigits::MXX_002. dem, mxx-003 Old german bank notes (DEM), see Algorithm::CheckDigits::MXX_003. ustid_at, vatrn_at, mxx-004 See Algorithm::CheckDigits::MXX_004. esr9_ch, mxx-005 See Algorithm::CheckDigits::MXX_005. verhoeff, mxx-006 Verhoeff scheme, see Algorithm::CheckDigits::MXX_006 or Algorithm::Verhoeff EXPORT None by default. SEE ALSO
perl, www.pruefziffernberechnung.de. AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de> THANKS
Petri Oksanen made me aware that CheckDigits('IMEI') would invoke no test at all since there was no entry for this in the methods hash. COPYRIGHT AND LICENSE
Copyright 2004-2006 by Mathias Weidner This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-06-06 CheckDigits(3pm)
All times are GMT -4. The time now is 04:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy