Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How to read multiple row text file by using In streams

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

0028.NEFT00004.txt

As per attached file is there any way to import this file into NAV tables by using stream.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to read multiple row text file by using In streams

    Dear Binesh,

    Thanks for help.

    Regards,

    Sandeep

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: How to read multiple row text file by using In streams

    Hello,

    Write some logic, something like:

    LOCAL ReadFile()
    MyFile.OPEN('c:\Temp\File1.txt');
    MyFile.CREATEINSTREAM(StreamInTest);
    WHILE NOT StreamInTest.EOS DO BEGIN
     StreamInTest.READTEXT(Buffer);
     //MESSAGE('%1',Buffer);
     j:= 1;
     FOR i := 1 TO STRLEN(Buffer) DO BEGIN
      IF (Buffer[i] = '|') THEN BEGIN
       CLEAR(CurrCellData);
       CLEAR(k);
       CLEAR(K_To);
       CLEAR(L);
       K_To := i;
       FOR k := j TO K_To-1 DO BEGIN
        L += 1;
        CurrCellData[L] := Buffer[k];
      END;
      MESSAGE('CurrCellData: %1',CurrCellData); // Test your data, you will get field wise data
      j := K_To + 1;
     END;
    END;
    END;

    // Here

    i,j,k,L, K_To is a Integer type variable and CurrCellData is A text Type.

    Based on your requirement you should write ur logic. 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to read multiple row text file by using In streams

    Dear Binesh,

    Thanks for reply but after reading data into buffer table how we can map table columns if buffer has multiple rows.

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: How to read multiple row text file by using In streams

    Check this

    forum.mibuso.com/.../importing-from-text-file

    forum.mibuso.com/.../importing-a-txt-file

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: How to read multiple row text file by using In streams

    Hello, You can read all lines in a file, see the bellow code:

    //LOCAL ReadFile()  ->
     MyFile.OPEN('c:\Temp\File1.txt');
     MyFile.CREATEINSTREAM(StreamInTest);
     WHILE NOT StreamInTest.EOS DO BEGIN
      StreamInTest.READTEXT(Buffer);
      MESSAGE('%1',Buffer);

      // here you can write your statements....
    END;

    //Local Variables:

    Name                 DataType
    MyFile                File
    StreamInTest      InStream
    Buffer                 Text

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans