MultiValue Tools

 View Only
  • 1.  Tab delimited file

    Posted 02-02-2023 12:24
    I am being asked to break a tab delimited file as part of an assessment. How do I identify the tab delimiter?

    ------------------------------
    Kimberly Crum
    Rocket Forum Shared Account
    ------------------------------


  • 2.  RE: Tab delimited file

    Posted 02-02-2023 12:49
    Hi Kimberly,

    The tab character is CHAR(9). You can get a section out of it with the
    FIELD function i.e. FIELD1 = FIELD(LINE,CHAR(9), 1). You can also use the
    CHANGE function to convert the line into a dynamic array and work with it
    like normal:

    LINE = CHANGE(LINE, CHAR(9), CHAR(254))
    FIELD1 = LINE<1>

    You might be able to use @AM in place of CHAR(254) depending on your MVDB
    version.

    Hope this helps.

    Joe Goldthwaite


    On Thu, Feb 2, 2023 at 10:23 AM Kimberly Crum via Rocket Forum <
    Mail@forum.rocketsoftware.com> wrote:

    > I am being asked to break a tab delimited file as part of an assessment.
    > How do I identify the tab delimiter? ------------------------------...
    > -posted to the "MultiValue Tools" forum
    > Invite your colleagues to join the Rocket Forum and grow our expert
    > network.
    > ------------------------------
    > [image: Rocket Software]


  • 3.  RE: Tab delimited file

    Posted 02-02-2023 14:35
    Thanks Joe.  I had my assessment yesterday and did use the FIELD statement with CHAR(9).  I have broken many flat files but never tab delimited. The key was figuring out what CHAR it was.  

    I appreciate your reply.

    ------------------------------
    Kimberly Crum
    Rocket Forum Shared Account
    ------------------------------



  • 4.  RE: Tab delimited file

    Posted 02-03-2023 09:29
    Kimberly,
    To add to previous responses.  If the tab delimited file is Unix then your end-of-line character is CHAR(10). If the tab delimited file is Windows then your end-of-line if CHAR(13):CHAR(10).  You may want to open the file in a HEX Editor to verify your data.


    ------------------------------
    Peter Gonzalez
    Programmer/Systems Analyst/EDI Developer
    Self Registered
    St. Louis MO US
    ------------------------------



  • 5.  RE: Tab delimited file

    Posted 02-10-2023 17:35

    Kimberly,

    I'd add that if the file is line-delimited (e.g.)

    abc <TAB> def <TAB> ghi <TAB> <END_OF_LINE>jkl <TAB> mno <TAB> pqr <TAB> <END_OF_LINE>stu <TAB> def <TAB> vwx<END_OF_LINE>

    It is better to use OPENSEQ/READSEQ (to exhaustion)/CLOSESEQ to process the file line-by-line rather than READ and loop on FIELD for the whole file.

    Regards

    JJ



    ------------------------------
    John Jenkins
    Thame, Oxfordshire
    ------------------------------



  • 6.  RE: Tab delimited file

    Posted 20 days ago
    Edited by John Isael 20 days ago

    I do this all the time.

    My box has lots of RAM, so reading in a large file is easy.

    READ record FROM F.FILE, XXX THEN

    record = CHANGE(record, CHAR(10), "")   ;* if on a UNIX box

    record = CHANGE(record, CHAR(9), @VM)

    AGAIN = @TRUE 

    LOOP

    WHILE AGAIN

       REMOVE ROW FROM record SETTING AGAIN

       * Now, each "cell" is its own multi-value in ROW and can be accessed as:

       * ROW<1,1>

       * ROW<1,2>

       * ect.

    REPEAT



    ------------------------------
    John Isael
    Rocket Forum Shared Account
    ------------------------------