Sponsored Content
Full Discussion: Cross Tab
Top Forums Shell Programming and Scripting Cross Tab Post 302971277 by radius on Monday 18th of April 2016 01:14:39 PM
Old 04-18-2016
Cross Tab

I need help to do cross tab

file input
Code:
20160101|ASIA|CHINA|2000
20160101|ASIA|INDIA|3000
20160102|ASIA|CHINA|4000
20160103|ASIA|CHINA|2000
20160103|AFRIKA|ZAMBIA|2000
20160104|ASIA|CHINA|5000

expected output
Code:
CONTINENT|NATION|20160101|20160102|20160103|20160104
ASIA|CHINA|2000|4000|2000|5000
ASIA|INDIA|3000|0|0|0
AFRIKA|ZAMBIA|0|0|2000|0

I did this
Code:
awk '
{
	for(i=1;i<=NF;i++)
		print $1,head[i-1],$i
}' input | awk -F'|' '{print ""CONTINENT""|""NATION""|"$0

 

8 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Cross Posting

In regards to this post: https://www.unix.com/showthread.php?s=&threadid=10372 it may be advisable to inform new members about the repercussions of cross-posting. (9 Replies)
Discussion started by: Karma
9 Replies

2. UNIX for Advanced & Expert Users

Cross platform Authentication

I am looking to have UNIX authenticate against Active Directory in a Windows Server 2003 environment, any suggestion? I am very new to UNIX, 2 weeks worth knowledge, if that. Thanks! (3 Replies)
Discussion started by: Optik
3 Replies

3. Shell Programming and Scripting

files cross over

I have many files (File 1, File 2, File 3, ...) in same directory. The format of all these files are same. What I would like to do is to combine all these files into a single file via cross over. Example) >>File 1 look like this. f1 01 1.0 f1 02 2.0 f1 03 3.0 f1 04 4.0 f1 05 5.0 f1 06... (2 Replies)
Discussion started by: Jae
2 Replies

4. HP-UX

nfs cross mount

how can I do nfs cross mount between two servers' nfs filesystems? should I put a wrapper or do I have to use /etc/rmtab ? advise me which method I have to use ? (2 Replies)
Discussion started by: xramm
2 Replies

5. Shell Programming and Scripting

Cross checking two files

i have two files which contains some fields separated by columns as 03/29/1999 08:48:12 02 172.16.114.50 03/29/1999 09:08:00 480 172.16.112.100 Both of the files do have the same format I want the script which will take two such... (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

6. Programming

Cross target debugging

I am trying to setup gdbserver debugging on my i386 target platform and running gdb from x86_64 host. I always get could not load vsyscal try using file etc.. error. Is there a clean way to setup a cross target gdb. PS: I also tried set archi i386 on host side. (2 Replies)
Discussion started by: dragonpoint
2 Replies

7. Linux

Cross compile

Hi, I'm cross compiling libelektra to arm from linux system its giving library errors can any one help me? (0 Replies)
Discussion started by: Gautham.P
0 Replies

8. Programming

what is a cross compiler

recently i was been to an interview to an automotive company, they have posed me a question that what section of compiler must be changed if the target is changed. ie,if ur compiler is meant for generating executable to a 8051 target what changes do you do to make it flexible to generate the... (2 Replies)
Discussion started by: shyam.sunder91
2 Replies
Locale::Codes::LangVar(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangVar(3pm)

NAME
Locale::Codes::LangVar - standard codes for language variation identification SYNOPSIS
use Locale::Codes::LangVar; $lvar = code2langvar('acm'); # $lvar gets 'Mesopotamian Arabic' $code = langvar2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langvar_codes(); @names = all_langvar_names(); DESCRIPTION
The "Locale::Codes::LangVar" module provides access to standard codes used for identifying language variations, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language variations. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lvar = code2langvar('en','alpha-2'); $lvar = code2langvar('en',LOCALE_CODE_ALPHA_2); The codesets currently supported are: alpha This is the set of alphanumeric codes from the IANA language registry, such as 'arevela' for Eastern Armenian. This code set is identified with the symbol "LOCALE_LANGVAR_ALPHA". This is the default code set. ROUTINES
code2langvar ( CODE [,CODESET] ) langvar2code ( NAME [,CODESET] ) langvar_code2code ( CODE ,CODESET ,CODESET2 ) all_langvar_codes ( [CODESET] ) all_langvar_names ( [CODESET] ) Locale::Codes::LangVar::rename_langvar ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangVar::add_langvar ( CODE ,NAME [,CODESET] ) Locale::Codes::LangVar::delete_langvar ( CODE [,CODESET] ) Locale::Codes::LangVar::add_langvar_alias ( NAME ,NEW_NAME ) Locale::Codes::LangVar::delete_langvar_alias ( NAME ) Locale::Codes::LangVar::rename_langvar_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangVar::add_langvar_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangVar::delete_langvar_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2014-01-06 Locale::Codes::LangVar(3pm)
All times are GMT -4. The time now is 03:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy