CSV botsid field position question

141 views
Skip to first unread message

Rohan

unread,
May 11, 2012, 12:41:34 AM5/11/12
to Bots Open Source EDI Translator
Hello,

We have been tasked with processing a CSV in the format:

800,00,xxxxxxxxx
800,01,xxxxxxxxx
800,05,xxxxxxxxx
800,05,xxxxxxxxx
800,05,xxxxxxxxx
800,99,xxxxxxxxx

where 00, 01, 05, and 99 are the record identifiers

800 has been placed at the start of every line in the file (it is the
file type).

I cannot use "800,00" or "800,01" as the BotsId because the fields are
parsed before this processing is done. eg. The first field becomes
"800" and the second "00".
It seems I cannot use startRecordId or endRecordId for the same reason
as this is not active for csv format.

Is there any way I can get BOTS to use the second field as the record
identifier in this CSV file?

Regards,
Rohan.

henk-jan ebbers

unread,
May 11, 2012, 6:17:51 AM5/11/12
to bots...@googlegroups.com
hi Rohan,

that is a funny format.
I will try this and come back later.

henk-jan

henk-jan ebbers

unread,
May 11, 2012, 9:11:49 AM5/11/12
to bots...@googlegroups.com
I checked this, is not in current bots. first field is BOTSID (except for fixed records)

seems it is relatively easy to adapt, but would need lots of testing...

you cna also read this in (using 800 as BOTSID) and have in mapping things like:
inn.get('BOTSID':'800', 'key':01, value:None)

is that workable?

henk-jan

On 05/11/2012 06:41 AM, Rohan wrote:

BikeMike

unread,
May 13, 2012, 7:33:54 AM5/13/12
to Bots Open Source EDI Translator
Hi Rohan,
You could also manage this by using preprocessing in a routescript.
Various alternatives could be coded, depending on whether you still
need the '800'.
* Strip off first 4 characters of each line
* Replace the first comma with a dash (so the BOTSID is 800-01)
* swap the order of the first 2 fields

Kind Regards,
Mike

----- example routescript for first alternative above -----
from bots.botsconfig import *
import bots.preprocess as preprocess
import bots.botslib as botslib
import bots.botsglobal as botsglobal

def postincommunication(routedict):
preprocess.preprocess(routedict,StripFirst4Characters)

def StripFirst4Characters(ta_from,endstatus,**argv):

# copy ta for preprocessing
ta_to = ta_from.copyta(status=endstatus)

# open the files
infile = botslib.opendata(ta_from.filename,'r')
tofile = botslib.opendata(str(ta_to.idta),'wb')

# strip the first 4 characters of each line
for line in infile:
line = line[4:]
tofile.write(line)

# close files and update outmessage transaction
infile.close()
tofile.close()
ta_to.update(statust=OK,filename=str(ta_to.idta))

Rohan

unread,
May 13, 2012, 5:23:23 PM5/13/12
to Bots Open Source EDI Translator
Hi Guys,

Thank you both for confirming that this is not an in-built function.
I had spent a considerable amount of time looking into this and
thought I had better check with the experts to make sure.

I think it is a funny format too.

Based on this feedback my first option will be to go back to the
client and see whether there interface files can have this first
(redundant) field removed.

Otherwise I think the pre-processing script would be the next best
option. Thanks Mike for putting that together. Much appreciated.

Kind regards,
Rohan.

Simon Inman

unread,
Jul 30, 2015, 6:08:32 AM7/30/15
to Bots Open Source EDI Translator, roh...@gmail.com
Hi Rohan

Were you able to come up with a solution that kept the first field as 800 and process the CSV?

Thanks
Simon

Rohan

unread,
Jul 30, 2015, 6:02:38 PM7/30/15
to Bots Open Source EDI Translator, roh...@gmail.com, simon....@gmail.com
Hi Simon,

I just looked back into my history and it turns out we were able to get the client to remove this first field from the csv altogether.

I believe at the time that the only other viable solution was to do some preprocessing on the file to remove the first column before bots processed it.

Cheers,
Rohan.
Reply all
Reply to author
Forward
0 new messages