Sponsored Content
Full Discussion: EDI File Parser
Top Forums Shell Programming and Scripting EDI File Parser Post 302932820 by Scrutinizer on Sunday 25th of January 2015 05:00:06 AM
Old 01-25-2015
When I executed your script, I get:
Code:
1000||||1234A~|1234A~|0.00~|99991231~|0.00|||||HELLO||12|1|||||||||||||05~|HELLO~|
1001||||1234A~|1234A~|0.00~|99991231~|0.00|||||HELLO||12|1|||||||||||||05~|HELLO~|

What OS and version and what awk are you using?

The commented line has faulty syntax. Just try replacing it with simple if statements..

I do not understand what the script is doing. For one I do not get this $100 stuff is that another way of assigning an empty string?.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with an (easy) parser

Hello, i'm workig with a file with structural information about biological macromolecules (proteins etc). In a certain file, the info is structured like this @<TRIPOS>MOLECULE blah 1 blah 2 blah 3 @<TRIPOS>MOLECULE foo 1 foo 2 foo 3 @<TRIPOS>MOLECULE mmm 1 mmm 2 mmm 3 I would... (7 Replies)
Discussion started by: aristegui
7 Replies

2. Shell Programming and Scripting

need a text parser

i need a simple text parser which can parse a data file created by a softwre so that i can export it to my mysqldb,, datafile created as one record per line with different number of fields. e.g datafile contains following. a=1, b=3, c=4 a=1, c=55, d=abcd a=5, b=hello, c=99, d=help now i... (12 Replies)
Discussion started by: sfaizan
12 Replies

3. Shell Programming and Scripting

How to Strip lines off Streamed EDI Output

Attached is a streamed EDI ANSI X12 output where the segment terminator/delimiter is a tilde ~ character. Is it possible to do the following pseudo-code in a unix script (using either sed, awk and/or grep)? Open file StreamedOutput.txt Search for ISA and delete the data up to the tilde ~ char... (7 Replies)
Discussion started by: sapedi
7 Replies

4. Shell Programming and Scripting

Compare EDI files by skipping selected Segments

Hi, I wanted to compare EDI files present in Two different Directories which can be related by the file names. While comparing the EDI files i have to skip selected segments such as "ISA" "IEA" and "GS" "GE" since this may have datetime stamp and different "Sender" "Receiver" Qual. and... (3 Replies)
Discussion started by: Sivas
3 Replies

5. Shell Programming and Scripting

parsing issue with edi file

Hello, We have edi files we need to do some extra parsing on. There is a line that shows up that looks like this: GE|8,845|000000000 We need to parse the file, find the line ( that begins with GE "^GE" ), and remove the comma(s). What is the easiest way to do that ? I know I can grab... (5 Replies)
Discussion started by: fwellers
5 Replies

6. SCO

Add memory and EDI hard disk space

Dear all I would like to know if you have face to the problems as add 1. 256 MB DDR Ram memory 2. IDE 40 GB slaved hard-disk my current machine is GA-SIML Rev 1.0, 1.6 GHz CPU, 1GB HDD, 256 MB DDR-Ram memory, as I add another 256 DDR-Ram, and 40 GB Slaved EDI Hard disk it, the systems... (1 Reply)
Discussion started by: TinhNhi
1 Replies

7. Programming

Parser

Hi Everyone I have an out put of multiple lines which I would like to parse and retrieve certain info from it. The output consists of multiple sections that starts with the line Client: and ends with STL tag: each section separated by an empty line. So basically somehting like Client: ... (10 Replies)
Discussion started by: bombcan1
10 Replies

8. Shell Programming and Scripting

File Parser

Hi need help parsing a file. I have tag fields and values in a file with delimiter |. sample records from the file listed below 8=value|9=value|35=value|49=value|56=value|34=value|50=value|48=value|10=value 8=value|9=value|35=value|49=value|56=value|34=value|51=value|48=value|10=value... (2 Replies)
Discussion started by: subramanian
2 Replies

9. Shell Programming and Scripting

Parser

Hi All, I am trying to create a parser to find out what cobol programs are being called by which JCL's. I need to search recursively until the main cobol program is found being called by a JCL. I tried to create a script but I am not able to generalize it. Can someone please help. ... (1 Reply)
Discussion started by: nua7
1 Replies

10. Shell Programming and Scripting

A Stanza File Parser in Pure ksh

As it was ultimately Don Craguns idea that saved the whole project i can as well give something back to the community. This is my stanza file parser, which was written only using ksh without any external programs. The stanza structure There is some inconsistency as to what exactly is meant by... (0 Replies)
Discussion started by: bakunin
0 Replies
Business::EDI(3pm)					User Contributed Perl Documentation					Business::EDI(3pm)

NAME
Business::EDI - Top level class for generating U.N. EDI interchange objects and subobjects. SYNOPSIS
use Business::EDI; my $edi = Business::EDI-new('d09b'); # set the EDI spec version my $rtc = $edi->codelist('ResponseTypeCode', $json) or die "Unrecognized code!"; printf "EDI response type: %s - %s (%s) ", $rtc->code, $rtc->label, $rtc->value; my $msg = Business::EDI::Message->new($ordrsp) or die "Failed Message constructor"; foreach ($msg->xpath('line_detail/all_LIN') { ($_->part(7143) || '') eq 'EN' or next; print $_->part(7140)->value, " "; # print all the 13-digit (EN) ISBNs } DESCRIPTION
The focus of functionality is to provide object based access to EDI messages and subelements. At present, the EDI input processed by Business::EDI objects is JSON from the edi4r ruby library, and there is no EDI output beyond the perl objects themselves. NAMESPACE
When you "use Business::EDI;" the following package namespaces are also loaded: Business::EDI::Segment_group Business::EDI::Message That's why the example message constructor in SYNOPSIS would succeed without having done "use Business::EDI::Message;" EDI Structure Everything depends on the spec. That means you have to have declared a spec version before you can create or parse a given chunk of data. The exception is a whole EDI message, because each message declares its spec version internally. EDI has a hierachical specification defining data. From top to bottom, it includes: Communication - containing one or more messages (not yet modeled here) Message - containing segment groups and segments Segment Group - containing segments Segment - containing composites, codelists and data elements Composite - containing multiple codelists and/or data elements Codelist - enumerated value from a spec-defined set Data Element - unenumerated value This module handles messages and everything below, but not (yet) communications. CLASS FUNCTIONS
Much more documentation needed here... new() Constructor OBJECT METHODS (General) value() Get/set accessor for the value of the field. code() The string code designating this node's type. The code is what is what the spec uses to refer to the object's definition. For example, a composite "C504", segment "RFF", data element "7140", etc. Don't be confused when dealing with CodeList objects. Calling code() gets you the 4-character code of the CodeList field, NOT what that CodeList is currently set to. For that use value(). desc() English description of the element. METHODS (for Traversal) part_keys() This method returns strings that can be fed to part() like: foreach ($x->part_keys) { something($x->part($_)) } This is similar to doing: foreach (keys %x) { something($x{$_}) } In this way an object can be exhaustively, recursively parsed without further knowledge of it. part($key) Returns subelement(s) of the object. The key can reference any subobject allowed by the spec. If the subobject is repeatable, then prepending "all_" to the key will return an array of all such subobjects. This is the safest and most comprehensive approach. Using part($key) without "all_" to retrieve when there is only one $key subobject will succeed. Using part($key) without "all_" to retrieve when there are multiple $key subobjects will FAIL. Since that difference is only dependent on data, you should always use "all_" when dealing with a repeatable field (or xpath, see below). Examples: my $qty = $detail->part('QTY'); # FAILURE PRONE! my @qtys = $detail->part('all_QTY'); # OK! xpath($path) $path can traverse multiple depths in representation via one call. For example: $message->xpath('all_SG26/all_QTY/6063') is like this function foo(): sub foo { my @x; for my $sg ($message->part->('all_SG26') { for ($sg->part('all_QTY') { push @x, $->part('6063'); } } return @x; } The xpath version is much nicer! However this is nowhere near as fully featured as W3C xpath for XML. This is more like a multple-depth part(). Examples: my @obj_1154 = $message->xpath('line_detail/SG31/RFF/C506/1154'); xpath_value($path) Returns value(s) instead of object(s). Examples: 'ORDRSP' eq $ordrsp->xpath_value('UNH/S009/0065') or die "Wrong Message Type!"; WARNINGS
This code is experimental. EDI is a big spec with many revisions. At the lower levels, all data elements, codelists, composites and segments from the most recent spec (D09B) are present. SEE ALSO
Business::EDI::Spec edi4r - http://edi4r.rubyforge.org AUTHOR
Joe Atzberger perl v5.12.4 2010-09-08 Business::EDI(3pm)
All times are GMT -4. The time now is 03:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy