Skip to Content
Aug 26, 2015 at 03:14 PM

Parse tab-delimited file


I am trying to parse a tab-delimited file but it fails everytime. The file is generated using the code

ls_ColName = TRIM(adw_object.Describe("DataWindow.Objects"))

Method 1: I created a external datawindow with one column in it. Then imported it to datawindow


Even though the above statement returns 1 but what it fails to create a stack of fields available in ls_ColName.

Method 2: Using POS and MID

String ls_ColName

ll_cnt = 0

long ll_pos, ll_mov

String ls_space, ls_objectType

String ls_mid

ls_space = ' ' //copied the space between fields from attached file

ll_mov = 1

ls_ColName = TRIM(adw_object.Describe("DataWindow.Objects"))

ll_len = Len(ls_ColName)

FOR ll_cnt = 1 TO ll_len

ll_pos = POS(ls_colName, ls_space, ll_cnt)

ls_mid = MID(ls_colName, ll_cnt, ll_pos - 1)

ls_mod = RIGHTTRIM(LEFTTRIM(ls_mid)) + ".Type"

ls_objectType = adw_object.describe(ls_mod)

ll_mov = ll_pos

ll_cnt = ll_pos


The problem in method 2 is after finding the first field and its type, its starts concatenating the rest which fails to give the type.

The tab separated file is attached for reference.