Using Split Functions

Problem: The NewYork screen presents cost center, account, and account description in one field, rather than in three fields. The three strings are separated by dashes (-). You want to present the three strings as three fields.


The image shows the contents of the NewYork GL screen. The contents are described in the text preceding the image

Solution: In the Import Formats screen, assign the following scripts, each of which uses the split function, to the Expression fields of the Entity, Account, and Account Description rows (first script to Entity, second script to Account, and third script to Account Description). The first script returns the set of characters before the first hyphen (a cost center value), the second script returns the set of characters after the first hyphen (an account value), and the third script returns the set of characters after the second hyphen (an account description value).

def NY_ParseCenter (strfield, strrecord):
    seglist = strfield.split("-")
    return seglist[0].strip()
def NY_ParseAccount (strfield, strrecord):
    seglist = strfield.split("-")
    return seglist[1].strip()
def NY_ParseDesc (strfield, strrecord):
    seglist = strfield.split("-")
    return seglist[2].strip()

Result: In the import file, cost center, account and account description strings are presented in three separate fields.