Search code examples
powerbuilder

PowerBuilder overwrite txt file to make it tab separated


i have an easy question but i m stack at the moment and i was wondering if anyone can help me out,

i need the part of code in PB that will overwrite a txt file and make it tab separated.

That is consider a insert.txt file with the following format

533#0000000000007851

594#0000000000006937

36#0000000000005667

....

and i want to overwrite it with PB code and make it like this

533 0000000000007851

594 0000000000006937

36 0000000000005667

......

so the # will be deleted and will become the tab...

I hope that you understand the question

Please some help i m so stack , any help would be really appreciated

Thank you in advance


Solution

  • Your answer is correct but could be simpler.

    1) import the file as single column

    2) Parse the values in each row looking for the '#' similar to this:

    integer li
    string ls_a, ls_b, ls_rowvalue
    FOR li = 1 TO dw_import.Rowcount()
      ls_rowvalue = dw_import.object.columnwithdata[li]
      ls_a = Right(ls_rowvalue, Pos(ls_rowvalue, "#") - 1)
      ls_b = Mid(ls_rowvalue, Pos(ls_rowvalue, "#") + 1)
      //put the values into a new datawindow
    NEXT
    dw_newvalues.Saveas("C:\temp\newstuff.txt)
    

    The default 'saveas' type is Text! which is tab separated.