04-09-2009
Parsing an irregular CSV file
To skip (that is, preserve) the other lines, just print them,
making sure that you DON'T do this when you add an "X".
nawk -F, ' NF == 3 { print $0 "X" ; next } {print} ' inputfile
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need a shell script that would parse this file
/usr/share/i18n/locales/aa_DJ:title "Afar language locale for Djibouti (Cadu/Laaqo Dialects)."
/usr/share/i18n/locales/aa_ER:title "Afar language locale for Eritrea (Cadu/Laaqo Dialects)."
/usr/share/i18n/locales/aa_ER@saaho:title... (2 Replies)
Discussion started by: eamani_sun
2 Replies
2. Shell Programming and Scripting
I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves.
Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies
3. Shell Programming and Scripting
Hi Scripting Gurus,
I am trying to parse a csv file and generate a new output file.
The input file will be a variable length in turns of rows and columns.
output file will have 8 columns. we have three columns from the header for each set.
just to give little bit more clarification each row... (15 Replies)
Discussion started by: vkr
15 Replies
4. Shell Programming and Scripting
#! /usr/local/bin/perl -w
$ip = "$ARGV";
$rw = "$ARGV";
$snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw";
$snmpw = "/usr/local/bin/snmpwalk -Os -c $rw";
$syst=`$snmpg $ip system sysName sysObjectID`;
sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies
5. Shell Programming and Scripting
Hello,
I have a file which contains groups of fields. These groups are separated by a blank line, to form a logical record.
Each line consists of a field-value pair.
If want to find all records where field 'd' has a value of '4' and if it does, I want the value of field 'a' (from the... (4 Replies)
Discussion started by: brawnr
4 Replies
6. UNIX for Dummies Questions & Answers
Hi Experts,
Im a new bee for scripting,
I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the... (2 Replies)
Discussion started by: pingnagan
2 Replies
7. Shell Programming and Scripting
Here is a data file, which I believe is in YAML. I am trying to retrieve just the 'addon_domains" section, which doesnt seem to be as easy as I had originally thought. Any help on this would be greatly appreciated!! I have been trying to do this in awk and mostly bash scripting instead of perl... (3 Replies)
Discussion started by: Rhije
3 Replies
8. Shell Programming and Scripting
Hey guys,
I have this file generated by me... i want to create some HTML output from it.
The problem is that i am really confused about how do I go about reading the file.
The file is in the following format:
TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies
9. Shell Programming and Scripting
Hi,
I have 2 files
format of file 1 is:
a1
b2
a2
c2
d1
f3
format of file 2 is (tab delimited):
a1 1.2 0.5 0.06 0.7 0.9 1 0.023
a3 0.91 0.007 0.12 0.34 0.45 1 0.7
a2 1.05 2.3 0.25 1 0.9 0.3 0.091
b1 1 5.4 0.3 9.2 0.3 0.2 0.1
b2 3 5 7 0.9 1 9 0 1
b3 0.001 1 2.3 4.6 8.9 10 0 1 0... (10 Replies)
Discussion started by: Lucky Ali
10 Replies
10. Shell Programming and Scripting
Hi Gurus,
i have files like this and i want to rename it.
server1_0_Log0000597500
server1_0_Log0000597501
server1_0_Log0000597502
server1_0_Log0000597503
server1_0_Log0000597504
server1_0_Log0000597505
server1_0_Log0000597506
server1_0_Log0000597507
server1_0_Log0000597508... (7 Replies)
Discussion started by: fedora132010
7 Replies
LEARN ABOUT DEBIAN
business::edi::spec
Business::EDI::Spec(3pm) User Contributed Perl Documentation Business::EDI::Spec(3pm)
NAME
Business::EDI::Spec - Object class for CSV-based U.N. EDI specifications
SYNOPSIS
use Business::EDI::Spec;
my $spec = Business::EDI::Spec->new('segment');
DESCRIPTION
CSV files originally from edi4r are included as part of Business::EDI. They are used to define the many different messages, segements,
data elements, composite data elements, and codelists that are part of a given version of the U.N. specification.
The CSV spec files are composed differently for the different structures defined. So we have to parse them differently.
==> Business/EDI/data/edifact/untdid/EDCD.d07a.csv # Composite Elements
CompositeCode;label;pos;code;mandatory;def;[pos;code;mandatory;def;...]
C001;TRANSPORT MEANS;010;8179;C;an..8;020;1131;C;an..17;030;3055;C;an..3;040;8178;C;an..17;
C002;DOCUMENT/MESSAGE NAME;010;1001;C;an..3;020;1131;C;an..17;030;3055;C;an..3;040;1000;C;an..35;
C004;EVENT CATEGORY;010;9637;C;an..3;020;1131;C;an..17;030;3055;C;an..3;040;9636;C;an..70;
C001 => {label => 'TRANSPORT MEANS;010;8179;C;an..8;020;1131;C;an..17;030;3055;C;an..3;040;8178;C;an..17;
==> Business/EDI/data/edifact/untdid/EDED.d07a.csv # Data Elements
code;def;class(?):label
1000;an..35;B;Document name
1001;an..3;C;Document name code
1003;an..6;B;Message type code
1000 => {label => 'an..35;B;Document name
==> Business/EDI/data/edifact/untdid/EDMD.d07a.csv # Messages
MessageCode:x:rel:org:z:SegmentGroup;label;SegCode;mandatory;repeats;[SegCode;mandatory;repeats;...]
APERAK:D:07A:UN::;Application error and acknowledgement message;UNH;M;1;BGM;M;1;DTM;C;9;FTX;C;9;CNT;C;9;SG1;C;99;SG2;C;9;SG3;C;9;SG4;C;99999;UNT;M;1
APERAK:D:07A:UN::SG1;SG01;DOC;M;1;DTM;C;99
APERAK:D:07A:UN::SG2;SG02;RFF;M;1;DTM;C;9
APERAK:D:07A:UN:: => {label => 'Application error and acknowledgement message',
UNH;M;1;
BGM;M;1;
DTM;C;9;FTX;C;9;CNT;C;9;SG1;C;99;SG2;C;9;SG3;C;9;SG4;C;99999;UNT;M;1
==> Business/EDI/data/edifact/untdid/EDSD.d07a.csv # Segments
SegCode;label;pos;code;class;repeats[pos;code;class;repeats;...]
ADR;ADDRESS;010;C817;C;1;020;C090;C;1;030;3164;C;1;040;3251;C;1;050;3207;C;1;060;C819;C;5;070;C517;C;5;
AGR;AGREEMENT IDENTIFICATION;010;C543;C;1;020;9419;C;1;
AJT;ADJUSTMENT DETAILS;010;4465;M;1;020;1082;C;1;
ADR => {label => 'ADDRESS',
010;C817;C;1;020;C090;C;1;030;3164;C;1;040;3251;C;1;050;3207;C;1;060;C819;C;5;070;C517;C;5;
==> Business/EDI/data/edifact/untdid/IDCD.d07a.csv # Composites (interactive)
E001 => {label => 'ADDRESS DETAILS;010;3477;M;an..3;020;3286;M;an..70;030;3286;C;an..70;040;3286;C;an..70;050;3286;C;an..70;060;3286;C;an..70;070;3286;C;an..70;
==> Business/EDI/data/edifact/untdid/IDMD.d07a.csv # Messages (interactive)
MsgCode:x:rel:org:z:SegmentGroup;label;SegCode;mandatory;class;repeats;;[mandatory;class;repeats;...]
IHCEBI:D:07A:UN::;Interactive health insurance eligibility and benefits inquiry and;UIH;M;1;MSD;M;1;SG1;C;9;SG2;C;1;UIT;M;1
IHCEBI:D:07A:UN::SG1;SG01;PRT;M;1;NAA;C;9;CON;C;9;FRM;C;9
IHCEBI:D:07A:UN::SG2;SG02;DTI;M;1;ICI;C;1;FRM;C;9;SG3;C;999
IHCEBI:D:07A:UN::SG3;SG03;BCD;M;1;HDS;C;9;DTI;C;1;PRT;C;9;FRM;C;9
IHCLME:D:07A:UN::;Health care claim or encounter request and response - interactive;UIH;M;1;MSD;C;1;PRT;C;9;NAA;C;9;CON;C;9;BLI;C;1;ITC;C;1;FRM;C;99;SG1;C;3;SG2;C;99;UIT;M;1
IHCLME:D:07A:UN::SG1;SG01;OTI;M;1;NAA;C;2
IHCLME:D:07A:UN::SG2;SG02;PSI;M;1;DNT;C;35
==> Business/EDI/data/edifact/untdid/IDSD.d07a.csv # Segments (interactive)
SegCode;label;pos;code;mandatory;repeats(?)
AAI;ACCOMMODATION ALLOCATION INFORMATION;010;E997;M;20;
ADS;ADDRESS;010;E817;C;1;020;E001;C;1;030;3164;C;1;040;3251;C;1;050;3207;C;1;060;E819;C;1;070;E517;C;1;
AAI => {label => 'ACCOMMODATION ALLOCATION INFORMATION',
pos => '010',
E997;M;20;
TO DO
Parsing for interactive specs.
SEE ALSO
edi4r - http://edi4r.rubyforge.org
Business::EDI
AUTHOR
Joe Atzberger
perl v5.12.4 2010-09-08 Business::EDI::Spec(3pm)