Simple csv to csv plugin

388 views
Skip to first unread message

Bill Butler

unread,
Jan 20, 2012, 12:08:19 AM1/20/12
to Bots Open Source EDI Translator
Is there a csv to csv plugin that I could download and install to get
my feet wet? I've used messageway and Gentran. This looks really
slick.

Thanks for your help in advance.

BikeMike

unread,
Jan 20, 2012, 12:30:36 AM1/20/12
to Bots Open Source EDI Translator
Hi Bill,
There is no csv to csv plugin, but there is edifact_orders2csv.zip.
For an example of csv input you could look at
alto_seperate_headers_details_1_6_0.zip in user contributed plugins
(although this is a little more complex).

There is "my_first_plugin_edifactorders2fixed_20111129.zip" which is
intended as a first introduction to bots. The tutorial on the new wiki
goes through this plugin, so it may be best to start with that even if
you don't know much about edifact.

http://code.google.com/p/bots/wiki/StartMyFirstPlugin

Good luck and let us know if you have any questions!

Kind Regards,
Mike

Bill Butler

unread,
Jan 20, 2012, 10:03:49 AM1/20/12
to Bots Open Source EDI Translator
Thanks Mike,

OK, my question stems from the following. In my past EDI life,
messageway had the concept of 'grammars', essentially templates
describing the in and out files. Regarding csv to csv, I'm afraid that
I don't understand the point of a tfile. It seems to me that if I can
define the grammar for the infile and the grammar for the outfile that
no tscript is really necessary. Is this a true statement? Essentially,
all I want to do is re-order a csv file and break it up into component
files.

input.csv
a,b,c,d,e,f,g,h,i,j

output1.csv
d,f,a,b

output2.csv
c,i

hjeb...@gmail.com

unread,
Jan 20, 2012, 10:33:04 AM1/20/12
to bots...@googlegroups.com
hi bill,

there is no build-in logic in bots for the concept of 'same fieldname'.
so you have to tell what field goes to what field (bots often deals with edi formats, which have a very elaborate stucture)

but I do think there is a tric for what you want.

there is a grammar for input.csv,
and a grammar for output1.csv
remove all fields you do not need in grammar output1 (so leave only d,f,a,b)
than in the syntax of the grammar:
'checkunknownentities': False,

you need a tfile, but is is very simple:

import bots.transform as transform

def main(inn,out):
transform.inn2out(inn,out)


(have not tried this myself, but I expect this to work. let me know if this works for you)

kind regards,
henk-jan

Bill Butler

unread,
Jan 20, 2012, 3:13:31 PM1/20/12
to Bots Open Source EDI Translator
Feeling pretty stupid here. I looked in the grammars dir on
sourceforge and there are only directories for edifact and x12. I'll
keep looking.

Bill Butler

unread,
Jan 20, 2012, 4:47:51 PM1/20/12
to Bots Open Source EDI Translator
I'm getting an error: 'no module named csv' when processing the input
file.

On Jan 20, 9:33 am, "hjebb...@gmail.com" <hjebb...@gmail.com> wrote:

BikeMike

unread,
Jan 20, 2012, 5:43:15 PM1/20/12
to Bots Open Source EDI Translator
Hi Bill,
There are no predefined grammars for csv, because of course csv is not
a standard. You will need to make your own, you can use one from one
of the plugins to get a start. In your route, the editype is csv, the
messagetype is whatever you call this format (eg. csvorders1). Then
you create a grammar matching this name, eg. bots/usersys/grammars/csv/
csvorders1.py

Kind Regards,
Mike

Bill Butler

unread,
Jan 21, 2012, 12:04:18 PM1/21/12
to Bots Open Source EDI Translator
Thanks,

Looks like I troubleshot all the grammar errors that came up and now
it's telling me that there is an extra separator at the end of the
record, which is true. My input file actually has 2 CR's at the end of
each record. Where do I define that in the 'in' grammar? Also, the
first definition in the grammar is the BOTSID. I just wanted to
clarify that the BOTSID is an internal reference and has nothing to do
with the contents of my file correct? Just don't want it to grab the
first column of my data and define it as BOTSID when is should be
defined as ACCTNUM. Cheers!



from bots.botsconfig import *

syntax = {
'field_sep':',',
'quote_char':'"',
'charset':"us-ascii",
'merge':True,
'noBOTSID':True
}

structure = [
{ID:'DTL',MIN:1,MAX:99999}
]

nextmessageblock = ({'BOTSID':'DTL','ACCTNUM':None})

recorddefs = {
'DTL':[
['BOTSID','C', 3, 'A'],
['ACCTNUM', 'C', 10, 'A'], # Account/PatientID
['VISITNUM', 'C', 10, 'A'], # Visit
['CLAIMID', 'C', 10, 'A'], # ClaimID
['PATIENTNAME', 'C', 50, 'A'], # Patient Full Name
['SSN', 'C', 9, 'A'], # SSN

BikeMike

unread,
Jan 21, 2012, 5:25:44 PM1/21/12
to Bots Open Source EDI Translator
Hi Bill,
The record separators can be defined in the syntax section. The
default for csv is 'record_sep':"\r\n", (you can find these in bots/
grammar.py defaultsyntax= for each editype). So you could try adding
'record_sep':"\r\n\r\n" (double CR-LF) in your grammar syntax.

You are correct about BOTSID, it is a required field on every record,
and normally "takes" the first field from the record. But
'noBOTSID':True in your syntax over-rides this, and instead BOTSID
will always contain the record name "DTL".

http://code.google.com/p/bots/wiki/GrammarsSyntax

Kind Regards,
Mike

Bill Butler

unread,
Jan 23, 2012, 1:57:04 AM1/23/12
to Bots Open Source EDI Translator
Awesome,

I successfully created an in and an out that writes a condensed
version of my input file into my output file. Just a few more things
and I'll be set. These are going to seem like very simple questions,
but I'm hoping everyone is patient with me.

1. As you can see, the header of my file has stuff at the beginning
that needs to be stripped out. Is there a way that I can specify for
the first 5 lines to be stripped out or ignored? I thought about using
info in the header to specify the trading partner too, but prob no
need since I'll be getting the data from a specific source and can
specify the trading partner.

2. The first piece of data is actually a customer number. A customer
may be listed more than once if they order more than 1 item. Ideally,
I need to build a customer list export followed by a product list. The
customer list would have just 5 records while the product list would
have 9. Is there a way to (a) build the csv customer list without
including duplicates (b) write the product list simultaneously.

I've oversimplified this for this example, but in reality, I'd like to
pass through the inbound file once and write to 5 csv tables as the
output, eliminating duplicates along the way.

Collection File: NATIONAL CUSTOMER LIST
Generated: 01/02/2012

Account #,Visit #,Char

113145,3660214,305720,

113145,3660214,305721,

114408,3660978,305735,

115774,3648888,296885,

130953,3660855,305936,

130953,3660855,305937,

112683,3647926,296363,

112683,3647926,296362,

112683,3647926,296364,

BikeMike

unread,
Jan 23, 2012, 5:40:03 AM1/23/12
to Bots Open Source EDI Translator
On Jan 23, 4:57 pm, Bill Butler <b...@butler.net> wrote:
> Awesome,
>
> I successfully created an in and an out that writes a condensed
> version of my input file into my output file. Just a few more things
> and I'll be set. These are going to seem like very simple questions,
> but I'm hoping everyone is patient with me.

Hi Bill,
Good to see you are making progress!

> 1. As you can see, the header of my file has stuff at the beginning
> that needs to be stripped out. Is there a way that I can specify for
> the first 5 lines to be stripped out or ignored?

Not quite as it stands, but a very small mod to bots code would allow
this. (maybe henk-jan would consider adding this to standard).
At the moment there us a syntax parameter for csv
'skip_firstline':True # or false
but this only skips one line. So I made a change in inmessage.py class
csv. This allows you to also specify an integer here, and skip that
many lines:
'skip_firstline':5 # skips the first 5 lines

Modify class csv like this:
if self.ta_info['skip_firstline']:
# if it is an integer, skip that many lines
# if True, skip just the first line
if isinstance(self.ta_info['skip_firstline'],int):
del self.records[0:self.ta_info['skip_firstline']]
else:
del self.records[0]

> 2. The first piece of data is actually a customer number. A customer
> may be listed more than once if they order more than 1 item. Ideally,
> I need to build a customer list export followed by a product list. The
> customer list would have just 5 records while the product list would
> have 9. Is there a way to (a) build the csv customer list without
> including duplicates (b) write the product list simultaneously.

For (a) you would need some logic in the mapping to do this, perhaps
appending to a list after checking if already in the list, then
outputting the whole list at the end. Or even using out.get(mpath) to
check if already written; if very large files are likely you might
want to test the speed of each approach.

For (b) actually you don't write them simultaneously, but one after
the other with a multiple step route and chained translations. The
first translation returns an "alt" value that triggers the next, and
so on for as many as you need. The last translation returns no alt and
so the chain of translations ends.

Everything you need to do is possible!

Kind Regards,
Mike

hjeb...@gmail.com

unread,
Jan 23, 2012, 8:49:19 AM1/23/12
to bots...@googlegroups.com

kind regards,
Henk-Jan Ebbers
www.ebbersconsult.com
t: 0031 30 2888358

Bots Open Source EDI Translator: http://bots.sourceforge.net

yes, that would be a nice enhancement!

henk-jan

Bill Butler

unread,
Jan 23, 2012, 8:10:11 PM1/23/12
to Bots Open Source EDI Translator
OK,

I'm pondering the various approaches here. The only thing that is
clear to me is that my input grammar needs to match the input file.
I'm really not clear on what the value nextmessageblock is intended to
represent in the input grammar. I set it to the first field with data
in my input file, but I don't understand its purpose.

nextmessageblock = ({'BOTSID':'DTL','GuarantorID':None})

recorddefs = {
'DTL':[
['BOTSID','C', 3, 'A'],
['GuarantorID', 'C', 255, 'A'], # Account/PatientID
['VISITNUM', 'C', 255, 'A'], # Visit


Next, I'm having a tough time understanding if I actually need a loop
or not. I constructed this map, but it just doesn't work the way I
expected. I've commented my intent by each line so maybe someone could
look at it and help me understand what I'm doing so wrong:

import bots.transform as transform

def main(inn,out):
patientrecord = "" #assign the variable
for lin in inn.getloop({'BOTSID':'DTL'}): # loop through each
DTL record
lastpatientrecord = lin.get({'BOTSID':'DTL','PatientID':None})
#assign the PatientID to the variable lastpatientrecord
if (lastpatientrecord <> patientrecord): # if it's not a duplicate,
set the variable duplicate to False
duplicate = False
else:
duplicate = True #if it is a duplicate, set the varable
duplicate to true
if not duplicate: #if it's not a duplicate pass the
record straight through
transform.inn2out(inn,out)
patientrecord = lin.get({'BOTSID':'DTL','PatientID':None})
#assign patientrecord = PatientID for the next loop through

BikeMike

unread,
Jan 23, 2012, 11:58:45 PM1/23/12
to Bots Open Source EDI Translator
On Jan 24, 11:10 am, Bill Butler <b...@butler.net> wrote:
> I'm really not clear on what the value nextmessageblock is intended to
> represent in the input grammar. I set it to the first field with data
> in my input file, but I don't understand its purpose.
>
> nextmessageblock = ({'BOTSID':'DTL','GuarantorID':None})

Hi Bill,
nextmessageblock is used to split one incoming file into multiple
sections (when the field value changes) but I think you want multiple
output files with each having details from the ENTIRE input file? In
that case you don't want to use it, just remove from the grammar.
http://code.google.com/p/bots/wiki/GrammarsNextmessage

> Next, I'm having a tough time understanding if I actually need a loop
> or not.

You will need a loop, but not the way you have done it.
transform.inn2out() is not used within a loop, it's probably no use to
you for this. Instead i would do something like this (just made this
up, but not tested!)

def main(inn,out):

# loop through each input DTL record
for lin in inn.getloop({'BOTSID':'DTL'}):

PatientID = lin.get({'BOTSID':'DTL','PatientID':None})
if PatientID != LastPatientID:

# loop output
lou = out.putloop({'BOTSID':'DTL'})

# Map PatientID to PatientID (assuming same record and
fieldnames in output)
lou.put({'BOTSID':'DTL','PatientID':PatientID})

# Map additional output fields here...

# Remember PatientID for duplicate check
# This assumes the input is grouped by PatientID
LastPatientID = PatientID


Kind Regards,
Mike

Bill Butler

unread,
Jan 24, 2012, 7:20:24 AM1/24/12
to Bots Open Source EDI Translator
Thanks Mike, this makes sense to me, although I do find it interesting
that I need to specify each field to map. Seems to me like there
should be a way to wildcard this. In other words, my output grammar is
already defined to contain the variables that I need in the order that
I need them. Doesn't it seem a bit redundant to need to to specify
them explicitly in the map?

To clarify, it seems like it should be possible for the map to act as
a filter for the entire record of data while the grammars handle the
specific columns and order of those columns. I'd imagine something
like this at the point of the loop doing the put:

lou.put({'BOTSID':'DTL','*':*})



On Jan 23, 10:58 pm, BikeMike <mjg1...@gmail.com> wrote:
> On Jan 24, 11:10 am, Bill Butler <b...@butler.net> wrote:
>
> > I'm really not clear on what the value nextmessageblock is intended to
> > represent in the input grammar. I set it to the first field with data
> > in my input file, but I don't understand its purpose.
>
> > nextmessageblock = ({'BOTSID':'DTL','GuarantorID':None})
>
> Hi Bill,
> nextmessageblock is used to split one incoming file into multiple
> sections (when the field value changes) but I think you want multiple
> output files with each having details from the ENTIRE input file? In
> that case you don't want to use it, just remove from the grammar.http://code.google.com/p/bots/wiki/GrammarsNextmessage

BikeMike

unread,
Jan 24, 2012, 4:31:55 PM1/24/12
to Bots Open Source EDI Translator
I think that is what henk-jan hinted at in post #4 above. But that
won't work if you also want to do the duplicate checking. If it was
just 100 records in = 100 records out you could do that.

I don't know if you can do transform.inn2out(lin,lou) within the
loop... might be worth a try. Or perhaps write a variation of this
function that can do this.

Kind Regards,
Mike

Bill Butler

unread,
Jan 24, 2012, 7:31:40 PM1/24/12
to Bots Open Source EDI Translator
Making a lot of progress now, and starting to understand mapping
better as a result. Now I'm stuck on the fact that I need to output to
two different files during this translation. I assumed that I'd be
able to set up 2 separate translations for this, but when I attempt to
do that, BOTS tells me that I cannot have 2 translations of the same
type for the same trading partner. The inbound channels are the same
but the outbound channels are different as follows:

fromeditype: csv
frommessagetype: my_in
Tscript: my_in2EDITrans
toeditype: csv
tomessagetype: EDITrans

I'd like to have a second translation performed on the same input
file:

fromeditype: csv
frommessagetype: my_in
Tscript: my_in2EDIPatient
toeditype: csv
tomessagetype: EDIPatient

As you can see, the first translation will pull the transactions
(Claims, Adjustments, Payment) from the infile and write them to
EDITrans while the second translation will pull the patient data from
the same infile and write it to EDIPatient.

The only problem is, I can't have them both setup at the same
time... ;) Do I have to make a single Map file that can do it all? If
so, how can I specify an alternative output grammar?

A little confused but still have hope.

BikeMike

unread,
Jan 25, 2012, 12:36:53 AM1/25/12
to Bots Open Source EDI Translator
Hi Bill,
In the first translation my_in2EDITrans.py add on the last line:
return 'EDIPatient'

then when you add your second translation in the bots gui, specify
EDIPatient in the alt field.

When bots gets a return value from a mapping script, it looks for
another translation matching this. We call this "chained translations"
and you can continue this as many times as you need, each with a
unique "alt" value.

Kind Regards,
Mike
Message has been deleted

BikeMike

unread,
Jan 25, 2012, 12:40:00 AM1/25/12
to Bots Open Source EDI Translator
The last mapping script has no return value, this is the end of the
chain

BikeMike

unread,
Jan 25, 2012, 7:36:11 AM1/25/12
to Bots Open Source EDI Translator

Bill Butler

unread,
Jan 25, 2012, 2:41:54 PM1/25/12
to Bots Open Source EDI Translator
Hmmm,

The terminology has me a little baffled. We have:

-Tscripts,
-Translations
-messagetypes
-grammars
-routes
-editype
-mapping scripts
-Alternative translations
-channels

Channels are well defined (in and out paths).
Tscripts, and mapping scripts appear to be one in the same.
Translations are possibly the combination of grammars and Tscripts/
mapping scripts
Grammars are messagetypes
Routes map translations to paths and tie them to trading partners.
Editype appears to be redundant for the purposed of classification

I hope that I'm wrong about the stuff above, because the nomenclature
is killing me!

Here is what I did per your suggestion

fromeditype: csv
frommessagetype: my_in
Tscript: my_in2EDITrans
toeditype: csv
tomessagetype: EDITrans
alternate translation: EDIPatient

fromeditype: csv
frommessagetype: my_in
Tscript: my_in2EDIPatient
toeditype: csv
tomessagetype: EDIPatient

I added return 'EDIPatient' to the bottom of TScript: my_in2EDITrans
(although I don't really understand why since I specified the
alternate translation in my first translation).

All I ended up with was the EDIPatient file. No EDITrans file was
generated. Just to recap, I can run one at a time successfully.

One question about this: When I string together translations, is it
running them simultaneously building EDITrans and EDIPatient
simultaneously or is it finishing EDITrans and then moving on to
EDIPatient? Also, what are we specifying in the return statement? Is
it the name of a Translation, or a TScript? Translations are
particularly weird in BOTS, because they aren't really named. For
instance, when I make a route, I give it a name, but a translation is
just a combination of stuff with no name.

If I get this figured out with your help, I will spend the time to
write a dedicated section of the WIKI devoted to this.

Bill Butler

unread,
Jan 25, 2012, 3:25:13 PM1/25/12
to Bots Open Source EDI Translator
I did finally get this working, but with a pretty major limitation. I
can't specify separate file names for the 2 different translations.
They both come out but they have the same file name with the serial
numbers incremented. Seems to me that the easiest thing to do would be
to eliminate the restriction on having multiple translations and allow
me to name my translations. Then I could set up a route that allowed
me to incorporate as many translations and channels as I desired.

Route ClientA

Channel Map Channel
infile_csv Translation outfile_Trans
inflie_csv Translation outfile_Patient


On Jan 25, 6:36 am, BikeMike <mjg1...@gmail.com> wrote:
> Added this to the wikihttp://code.google.com/p/bots/wiki/TranslationAlt

BikeMike

unread,
Jan 25, 2012, 4:19:04 PM1/25/12
to Bots Open Source EDI Translator
Hi Bill,
re the naming, you are right.
Translation is the setup in the GUI, it doesn't have a name (primary
key) as such, but a set of values that, in combination, cause it to be
selected. Alt (alternative translation) is one of these values, and
the alt value can be set in multiple ways (as per my wiki page).
.
Mapping / Mapping Script / Tscript all refer to the same thing; your
python code for mapping. If you have a return (alt) value in a mapping
script, you must configure a corresponding translation to be triggered
by it.

editype is one of the types supported by bots. messagetype is the name
you give each one, corresponding to your grammar file name.

For multiple output with different filenames and/or destinations, you
configure a multi-step route. Each route entry has a sequence number,
so you can configure (with the same route name) sequence 10, 20, etc.
Each route has "filtering for outchannel" where you can enter your
editype and messagetype (or partners), and of course each route
sequence can have a different outchannel, which in turn specifies the
filename and location.

For multiple seq routes I set them up this way (there are a few
possibilities):
seq 10: Has inchannel configured, translate ticked, first outchannel,
filtering by editype and messagetype for the first file. (if this was
the only step configured, your second translated file would be "stuck"
in bots, because it doesn't know where to send it.)
seq. 20: Has no inchannel, translate not ticked, second outchannel
configured with filtering for the second file.

The other way to do it is with 3 sequences, first does the input/
translation with no outchannel. 2nd & 3rd configure the outchannels,
no input/translation. This may be clearer to understand, it just means
more route steps.

The files are not translated simultaneously, but one after the other.
A return in the mapping script is specifying an alt value, which is a
key field to find translation, can be anything you configure, not
necessarily matching the name of a mapping script.

Kind Regards,
Mike

BikeMike

unread,
Jan 25, 2012, 4:25:19 PM1/25/12
to Bots Open Source EDI Translator
I'm updating the wiki as questions come up. Maybe a glossary of terms
is a good idea to add.

hjeb...@gmail.com

unread,
Jan 25, 2012, 5:01:52 PM1/25/12
to bots...@googlegroups.com
yes, you can.
use outchannel in the same route (and filter for the outchannels)
see http://code.google.com/p/bots/wiki/RoutesComposite

henk-jan

hjeb...@gmail.com

unread,
Jan 25, 2012, 5:54:53 PM1/25/12
to bots...@googlegroups.com

On 01/25/2012 08:41 PM, Bill Butler wrote:
> Hmmm,
>
> The terminology has me a little baffled. We have:
>
> -Tscripts,

you are right, this is confusing. they should be called mapping scripts, I will change this in the interface.


> -Translations
> -messagetypes
> -grammars
> -routes
> -editype
> -mapping scripts
> -Alternative translations
> -channels
>
> Channels are well defined (in and out paths).
> Tscripts, and mapping scripts appear to be one in the same.

these are these same, yes. tscript should disappear!


> Translations are possibly the combination of grammars and Tscripts/
> mapping scripts

each messagetype is defined in a grammar (records, fields, etc).
a translation uses a mapping script
a translation is being define in the GUI, it refers to a mapping script

> Grammars are messagetypes
a messagetype is defined in a grammar.


> Routes map translations to paths and tie them to trading partners.

I do not know what you have in mind here.


> Editype appears to be redundant for the purposed of classification

I am not a native speaker of english, it is not clear to me what you have in mind here.


> I hope that I'm wrong about the stuff above, because the nomenclature
> is killing me!

your post is indeed helping to get the se names better and more clear! thank you.


> Here is what I did per your suggestion
>
> fromeditype: csv
> frommessagetype: my_in

might wanna choose a name that has more meaning. Eg orders, invoices? what document is coming in?
> Tscript: my_in2EDITrans
I try to use the name systematic as: <fromeditype><<frommessagetype>2<toeditype><tomessagetype>
> toeditype: csv
> tomessagetype: EDITrans
try to use something that has a meaning to your business process.


> alternate translation: EDIPatient
>
> fromeditype: csv
> frommessagetype: my_in
> Tscript: my_in2EDIPatient
> toeditype: csv
> tomessagetype: EDIPatient
>
> I added return 'EDIPatient' to the bottom of TScript: my_in2EDITrans
> (although I don't really understand why since I specified the
> alternate translation in my first translation).
>
> All I ended up with was the EDIPatient file. No EDITrans file was
> generated. Just to recap, I can run one at a time successfully.

yes, and I can see why: it should be at the end of the my_in2EDIPatient script.
the id's used here get quite confusion.
maybe an alt ID like 'do_the_2nd_translation:EDItrans' would be better.
my 'alt' names have the tendency to be long and descriptive, I hope you understand why.

> One question about this: When I string together translations, is it
> running them simultaneously building EDITrans and EDIPatient
> simultaneously or is it finishing EDITrans and then moving on to
> EDIPatient?

see below how it works, but translations are done one after the other.


> Also, what are we specifying in the return statement?

works likes this:
- bots parses the incoming message, using the fromeditype and frommessagetype to find the right grammar.
- bots looks up in the translation table, with fromeditype and frommessagetype as keys.
It will find the mappingscript (in your case: my_in2EDIPatient), the toeditype (csv) and tomessagetype (EDIPatient)
- the mappingscript is run, and produces the EDIPatient-outgoing files (within bots, actual output is later)
- the mapping script ends with return 'EDIPatient'
- bots will again look in the translation table, with fromeditype and frommessagetype as keys but 'EDIpatient' as 'alt' (is used as extra key in the lokup)
For this 2nd translation bots will find the mappingscript (in your case: my_in2EDITrans), the toeditype (csv) and tomessagetype (EDITrans)
- the mappingscript is run, and produces these outgoing files (within bots, actual output is later)
- the mapping script does not send an 'alt' value, and bots will not do another translation for the incoming file

hope this makes it more clear.


> it the name of a Translation, or a TScript? Translations are
> particularly weird in BOTS, because they aren't really named.

yes, that is weird.
it might have been better to use the name of the mapping script as the name of the translation.
I have to think about this.
I guess this did not feel right, because (fromeditype, frommessageetype, alt etc) is the key.

> For
> instance, when I make a route, I give it a name, but a translation is
> just a combination of stuff with no name.

yes.


> If I get this figured out with your help, I will spend the time to
> write a dedicated section of the WIKI devoted to this.

great.


The topic of sensible naming of all these things is quite important (for me).
I have lots of setups (I do commercial services for bots).
when I look at a setup I haven't seen for a year, I want to understand fast what everything does.

eg I mostly use for naming routes and channels:

route: inbound_<name company>
inchannel: inbound_<name company>_in
outchannel: inbound_<name company>_out

(where inbound means: coming into your company)

kind regards,
Henk-Jan Ebbers


Bill Butler

unread,
Jan 25, 2012, 9:23:48 PM1/25/12
to Bots Open Source EDI Translator
I ended up doing this with 2 routes. The first route named (Route1)
with a priority of 10 reads the infile, translates and outputs the
EDITrans file. The second route also named (Route1) with a priority of
11 just outputs the EDIPatient file (no infile or translation chosen).
Also, no filter was needed.

Pretty slick overall but not particularly intuituve ;)

I was trying to get ftps running with python 2.7.2. Not looking
promising yet, but still chugging away.

On Jan 25, 4:01 pm, "hjebb...@gmail.com" <hjebb...@gmail.com> wrote:
> yes, you can.
> use outchannel in the same route (and filter for the outchannels)
> seehttp://code.google.com/p/bots/wiki/RoutesComposite

BikeMike

unread,
Jan 26, 2012, 12:04:13 AM1/26/12
to Bots Open Source EDI Translator
Hi Bill,
Good to hear you have it working (almost).

From a terminology point of view we would say that is one route with
two steps (or sequences), not two routes with different priority. Not
sure how you would do it without filtering, I suspect both outputs are
actually still going to the first seq outchannel still? The second seq
is only needed (with some filtering used on both) to separate the two
outputs to two channels so you can also set different filenames.

You are right that it's not completely intuitive, but I guess nothing
in EDI is! You will always need someone technical to manage it. Also I
believe if you try to make something "too simple" you often end up
limiting it's capabilities and sacrificing the flexibility. Of course
if you have suggestions for improvement to either Bots or the
documentation wiki they are welcome.

I haven't used ftps myself but do use ftp, and sftp (which has some
dependencies, paramiko and pycrypto). Not sure if there are any
dependencies for ftps, you should see a warning/error if so.

Kind Regards,
Mike

Bill Butler

unread,
Jan 30, 2012, 9:50:30 AM1/30/12
to Bots Open Source EDI Translator
That was the trick. I ended up getting this to work by defining the
first route with the infile, translation and outfile. Then I named the
second route the same but with a different priority and just named the
outfile. It wasn't that intuitive, but it works. I view EDI as a
series of paths and I find it strange that you'd build in
functionality to string translations together. Seems that it would
make a lot more sense to map grammars to maps and then back to
grammars in any combination that the user sees fit. Also, I'd envision
a page that actually gives you a popup list of all of your grammars
instead of forcing you to type in the grammar. I understand the
concept of channels, but it seems like there should be a more
intuitive way to handle this as well. Tying a grammar back to a
channel isn't really intuitive. Seems like that could also just be
part of the route...for instance:

Route A: priority 10

Inbound transport: ftp:21:username:password
Inbound Grammar: grammar-in
Map: maptrans
Outbound Grammar: grammar-trans-out
Outbound transport: smtp:25:us...@domain.com

Route A: priority 20

inbound transport: ftp:21:username:password
Inbound Grammar: grammar-in
Map: mappatients
Outbound Grammar: grammar-patients-out
Outbount transport: smtp:25:user@domain

Letting the route handle all the heavy lifting means fewer exceptions
and creates a more understandable flow in my opinion. A good
compromise may be to define transports under the trading partners and
have the transport methods be auto-selected based upon the trading
partner defaults when you set a up a new route, with the ability to
override those prefs in the route. Ultimately, I'd expect that a route
could be built as a self contained entity rather than having multiple
routes with priority.

On Jan 25, 4:01 pm, "hjebb...@gmail.com" <hjebb...@gmail.com> wrote:
> yes, you can.
> use outchannel in the same route (and filter for the outchannels)
> seehttp://code.google.com/p/bots/wiki/RoutesComposite

hjeb...@gmail.com

unread,
Jan 30, 2012, 10:11:08 AM1/30/12
to bots...@googlegroups.com
problem is: in edi (x12, edifact) one gets often multiple messagetypes in though the same channel.

henk-jan

On 01/30/2012 03:50 PM, Bill Butler wrote:
> That was the trick. I ended up getting this to work by defining the
> first route with the infile, translation and outfile. Then I named the
> second route the same but with a different priority and just named the
> outfile. It wasn't that intuitive, but it works. I view EDI as a
> series of paths and I find it strange that you'd build in
> functionality to string translations together. Seems that it would
> make a lot more sense to map grammars to maps and then back to
> grammars in any combination that the user sees fit.

that is what the translation table does, doesn't it?
or do you have something else in mind?


> Also, I'd envision
> a page that actually gives you a popup list of all of your grammars
> instead of forcing you to type in the grammar.

yes, that would be a good idea.

> I understand the
> concept of channels, but it seems like there should be a more
> intuitive way to handle this as well. Tying a grammar back to a
> channel isn't really intuitive.

I am not sure what you have in mind here.


> Seems like that could also just be
> part of the route...for instance:
>
> Route A: priority 10
>
> Inbound transport: ftp:21:username:password

problem is: some channels have much more parameters than that.


kind regards,
Henk-Jan Ebbers

Reply all
Reply to author
Forward
0 new messages