Sponsored Content
Top Forums Shell Programming and Scripting Split file when value in column is blank Post 303010744 by as7951 on Saturday 6th of January 2018 08:06:01 AM
Old 01-06-2018
Split file when value in column is blank

Hi Experts,

In short : Need to split file when field in column 5 is blank and need to generate two file in which column 5 is blank and other in which column 5 has values along with other rows and column data

My issue is i am not able to get header for column from raw file into new file which is generated by below command.
Code:
awk -F"|" -v OFS="|" '{if ($5 == "") print;}' test1.txt

Current output without header
Code:
KE|KE_OUTWARD_B2B_OSR_TT_TT_201025_V1.0.txt|30|||Outward|KAR|PO|082017|29AAACT24|INV|TAX|3010482048|2017-11-03||||1|29AAACH27|||M/s HD . LTD||||29||||||9984||Tel Ser|||||0.00|0.00|9.00|45.00|9.00|45.00|||||590.00||||||||||

Expected output should be with header like below
Code:
SOUFIER|SOUAME|GLACCODE|DIVISION|SUSION|PR1|PR2|PLADE|RETURNPERIOD|SUPPIN|DYPE|SUYPE|DOMBER|DOTE|ORIENTNUMBER|RIDATE|CRGST|LIBER|CUTIN|UINORON|ORIGIG|CUSTME|CUSTOMERCODE|BILTE|SHIPTE|POS|PODE|SHIMBER|SHTE|FOB|EXY|HSNORSAC|PRODUCTCODE|PRODIPTION|CATEDUCT|UNITONT|QUANTITY|TAUE|INTERATE|INTEEDTOUNT|CENTATE|CENTOUNT|STAATE|STATUNT|CEOREM|CESOREM|CESCIFIC|CESCIFIC|INVE|REVFLAG|TCSFLAG|ECOMGSTIN|ITCFLAG|REASONBITNOTE|ACCOUNTMBER|ACCOUNTINGVOUCHERDATE|USERDEFI|USERD|USE
KEN|KE_OUT_B2B_OSR_TT_TT_201025_V1.0.txt|22|||Outward|KAR|PO|082017|29A38A1ZP|INV|TA|3010048|2017-11 03||||1|29AAAZW|||M/s HD. LTD||||29||||||9984||Tel Ser|||||0.00|0.00|9.00|45.00|9.00|45.00|||||590.00||||||||||


Last edited by as7951; 01-06-2018 at 09:43 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Blank column in a file.

hi, Please tell me a way in which i can find out all the blank columns in the file which is pipe-delimited.after finding the blank column i want to find the line number. (8 Replies)
Discussion started by: Mohit623
8 Replies

2. Shell Programming and Scripting

Help me! grep the log file without blank lines in column

Hi, I have log file like this: i want grep the log file without blank lines in column 4. So the file is become like this : What is the command? please help me. (1 Reply)
Discussion started by: justbow
1 Replies

3. Shell Programming and Scripting

Split file by column value

Please help me figure out whats wrong with my code, I have to split a file according to values in 3rd thru 6th column, If the 3rd or 4th col values are >0, row goes to 1 file, if 3rd and 5th are >0,row goes to another file...and so on... What is wrong with my code? It doesn't seem to work.... (2 Replies)
Discussion started by: newbie83
2 Replies

4. Shell Programming and Scripting

Split the file based on column

Hi, I have a file sample_1.txt (300k rows) which has data like below: * Also each record is around 64k bytes 11|1|abc|102553|125589|64k bytes of data 10|2|def|123452|123356|...... 13|2|geh|144351|121123|... 25|4|fgh|165250|118890|.. 14|1|abc|186149|116657|......... (6 Replies)
Discussion started by: sol_nov
6 Replies

5. UNIX for Dummies Questions & Answers

Split file based on column

i have file1.txt asdas|csada|130310|0423|A1|canberra sdasd|sfdsf|130426|2328|A1|sydney Expected output : on eaceh third and fourth colum, split into each two characters asdas|csada|13|03|10|04|23|A1|canberra sdasd|sfdsf|13|04|26|23|28|A1|sydney (10 Replies)
Discussion started by: radius
10 Replies

6. UNIX for Dummies Questions & Answers

Split file based on number of blank lines

Hello All , I have a file which needs to split based on the blank lines Name ABC Address London Age 32 (4 blank new line) Name DEF Address London Age 30 (4 blank new line) Name DEF Address London (8 Replies)
Discussion started by: Pratik4891
8 Replies

7. Shell Programming and Scripting

Split multiple blank, even if it's blank

Hello, I am trying to split : qvipari1 opcmsga OVO Message Agent AGENT,EA Aborted qvipbcarls02 opcmsga OVO Message Agent AGENT,EA Aborted qvipcac3 perfalarm Alarm generator ... (10 Replies)
Discussion started by: cterra
10 Replies

8. Shell Programming and Scripting

Split file by column value, each with header

Hello all, I have a csv with with different testcase values in column 5. year,min,max,Instrument,Testcase 2016,201,1003,GEOTROPH-02116,TATA7980 2016,53,1011,GEOTROPH-01963,TATA7980 2016,3,1024,GEOTROPH-02067,TATA7980 2016,203,1027,GEOTROPH-02011,TATA7980... (16 Replies)
Discussion started by: senhia83
16 Replies

9. Shell Programming and Scripting

How to split a file into column with awk?

The following is my code nawk -F',' ' BEGIN { printf "MSISDN,IMSI,NAM,TS11,TS21,TS22,OBO,OBI,BAIC,BAOC,BOIC,BOIEXH,APNID0,APNID1,APNID2,APNID3,APNID0,CSP,RSA\n" } { for(i=1; i<=NF; i++) { split($i,a,":") gsub(" ","", a) printf "%s;",a } printf "\n" }'HLR_DUMP_BZV >> HLR_full This is... (1 Reply)
Discussion started by: gillesi
1 Replies

10. Shell Programming and Scripting

Split column when value in column is blank in any row

Hi Experts, In short : Need to split file when field in column 5 is blank and need to generate two file in which column 5 is blank and other in which column 5 has values along with other rows and column data My issue is i am not able to get header for column from raw file into new file which... (1 Reply)
Discussion started by: as7951
1 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, 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 extensions. 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: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_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 2013-11-04 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 02:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy