EDI Parsing and Extraction into XML

Emile van Sebille emile at fenx.com
Sat Sep 23 18:44:06 EDT 2000


Noah,

I've got some utilities I've written that allow me to map
EDI documents into python dictionaries.  They're certainly
not ready for prime time, but they get the job done and
allow me to do things in a comfortable way.  For example, by
defining a map of extraction rules, and then applying the
map to a transaction set, I get a dictionary with requested
header data fields, and a list of dictionaries each
containing the detail record fields.  At the moment, I've
only focussed on 850, 852 and 855 transaction sets for UCS
4010, as we're doing VMI by accepting 852s, and generating
850s and 855s.


Example Map & Usage:

fieldMap852 = {
          'hdr':[('XQ02','Date', '00000000'),
                 ('N102*N101=ST','Name', ''),
                 ('N103*N101=ST','DunsIDType', ''),
                 ('N104*N101=ST','DunsID', ''),
                 ('N401','City', ''),
                 ('N402','State', ''),
                 ('N403','Zip', ''),
                 ],
          'dtl':[('LIN03','CustItem', ''),
                 ('LIN05','ItemUPC', ''),
                 ('LIN09','TType', ''),
                 ('N902*N901=VN','VendID', ''),
                 ('ZA02*ZA01=QA', 'Avail', 0),
                 ('ZA02*ZA01=QC', 'Rsvrd', 0),
                 ('ZA02*ZA01=QD', 'FutureReqQty', 0),
                 ('ZA05*ZA01=QD', 'FutureReqDate', ''),
                 ('ZA02*ZA01=QN', 'Fcast', 0),
                 ('ZA02*ZA01=QO', 'StkOut', 0),
                 ('ZA02*ZA01=QP', 'OnPOs', 0),
                 ('ZA02*ZA01=QS', 'QtySld', 0),
                 ('ZA02*ZA01=QT', 'AdjQty', 0),
                 ('ZA02*ZA01=QW', 'WthDrn', 0),
                 ]
            }

ediDoc = EdiXn(rawEDItransaction)
ediDoc.mapFields(fieldMap852)
print "%(Name)20s  %(Date)20s  %(City)20s  %(DunsID)20s" %
ediDoc.header
for detail in ediDoc.details:
    print  detail['Avail'] , detail['Rsvrd'] ,
detail['OnPOs'] , detail['WthDrn']

---end of example---

If this is of interest as a starting point, contact me
directly as I'd also be interested in taking it on to XML
capabilities.

Assuming-you-can-get-from-dictionary-to-XML-ly y'rs,

--

Emile van Sebille
emile at fenx.com
-------------------


<noahspurrier at my-deja.com> wrote in message
news:8qj4j6$l2k$1 at nnrp1.deja.com...
> Has anyone here done any EDI message data extraction using
Python?
>
> We are receiving shipment and inventory info in EDI format
846 and 856
> when are sending purchase orders as EDI 850.
>
> I would like to convert the incoming EDI into our own XML
format.
> The few EDI/XML tools that I have found try to encompass
the
> entire EDI specification in an XML format. This is not
what I want
> to do. I just want to extract and map data from a
particular
> subset of EDI into our XML. Most XML translation tools
translate
> from XML TO a given format. I want to go the other way.
> Any general purpose flat-file text to XML mappers out
there?
>
> Suli Ding's doc2xml comes close to what I want:
>     http://www.geocities.com/SiliconValley/Platform/4871/
> But this does not have source code and is only built for
Win32.
>
> Any tips, Pythonian or non-Pythonian are appreciated.
>
> Noah Spurrier
> San Francisco
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




More information about the Python-list mailing list