Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading EDI Formatted Files

Tags:

parsing

edi

x12

I'm new to EDI, and I have a question.

I have read that you can get most of what you need about an EDI format by looking at the last 3 characters of the ISA line. This is fine if every EDI used line breaks to separate entities, but I have found that many are single line files with any number of characters used as breaks. I have noticed that the VERY last character in every EDI I've parsed is the break character. I've looked at a few hundred, and have found no exceptions to this. If I first grab that character, and use that to obtain the last 3 of the ISA line, should I reasonably expect that I will be able to parse data from an EDI?

I don't know if this helps, but the EDI 'types' in question tend to be 850, 875. I'm not sure if that is a standard or not, but it may be worth mentioning.

like image 227
Brandon Avatar asked Jan 22 '10 14:01

Brandon


People also ask

What format are EDI files in?

What is EDI file format? An EDI file is a data file structured using one of the various Electronic Data Interchange (EDI) standards. It contains information stored in plain text format.

Can you convert EDI to Excel?

To translate inbound documents from EDI to Excel, you use the CData Arc Excel connector to visualize EDI documents in Excel spreadsheets. The Excel Connector comes pre-configured with a template Excel file that generates stylized and formatted Excel sheets out of EDI XML.

What are the two formats of EDI?

Simple EDI file formats: variable and fixed flat files.


1 Answers

the transaction type of edi doesn't really matter (850 = order, 875 = grocery po). having written a few edi parsers, here are a few things i've found:

you should be able to count on the ISA (and the ISA only) being fixed width (105 characters if memory serves). strip off the first 105 characters. everything after that and before the first occurance of "GS" is your line terminator (this can be anything, include a 0x07 - the beep - so watch out if you're outputting to stdout for debugging or you may have a bunch of beeps coming out of the speaker). normally this is 1 or 2 characters, sometimes it can be more (if the person sending you the data adds an extra terminator for some reason). once you have the line terminator, you can get the segment (field) delimiter. i normally pull the 3 character of the GS line and use that, though the 4th character of the ISA line should work as well.

also be aware that you can get a file with multiple ISA's in it. in that case you cannot count on the line or field separators being the same within each ISA.

another thing .. it is also possible (again, not sure if its spec) for an edi file to have a variable length ISA. this is very rare, but i had to accommodate it. if that happens you have to parse the line into its fields. the last field in the ISA is only a character long, so you can determine the real length of the ISA from it. if it were me, i wouldn't worry about this unless you see a file like it. it is a rare occurance.

what i've said above may not be to the letter of the "spec" ... that is, i'm not sure its legal to have different line separators in the same file, but in different ISAs, but it is technically possible and I accommodate it because i have to process files that come through in that manner. the edi processor i use processes upwards of 5000 files a day with over 3000 possible sources of data (so i see a lot of weird stuff).

best regards, don

like image 184
Don Dickinson Avatar answered Sep 22 '22 05:09

Don Dickinson