web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Split text by new lines

(0) ShareShare
ReportReport
Posted on by 61

Hello guys,

I'm trying split a CSV-text into the array of separate lines. I have a Text array, where the CSV-text is stored, it looks like following:

"Header1, Header2, Header3

Value1, Value2, Value3

Value4, Value5, Value6"

In order to split the text I tried following constructions:

Text.Split('\n');

Text.Split('\\n');

Text.Split('\r\n');

Neither of the above mentioned versions work.

Maybe someone could advise what is the proper way to split text by new lines?

I have the same question (0)
  • Verified answer
    Alok.kulshreshtha Profile Picture
    934 on at
    RE: Split text by new lines

    Hi

    Try below

    CRLF[1] := 13; (if 13 not work than try 10)

    Value1, Value2, Value3 + CRLF[1] + Value4, Value5, Value6

    Regards,

    Alok Kulshreshtha

    Please Verify my answer if you find my post helpful.

  • Johny Be Good Profile Picture
    61 on at
    RE: Split text by new lines

    Hi Alok!

    Thank you for your reply!

    I tried your advice, but it didn't work, maybe I did something wrong.

    I used following file as an example - people.sc.fsu.edu/.../addresses.csv

    ...

    Client.Get('people.sc.fsu.edu/.../addresses.csv', Response);

    Response.Content.ReadAs(Body);

    Exit(Utils.Parse(Body));

    ...

    codeunit 50100 Utils

    {

       procedure Parse(CSV: Text): List of [Text];

       var

           result: List of [Text];

           CRLF: Integer;

       begin

           CRLF := 13;

           result := CSVText.Split(Format(CRLF));

           Exit(result);

       end;

    }

    Also I tried 10 instead of 13, but it didn't work either

  • Johny Be Good Profile Picture
    61 on at
    RE: Split text by new lines

    Ah, yeah...

    I used the wrong type for the new line code

    Here is working version:

       procedure Parse(CSV: Text): List of [Text];

       var

           result: List of [Text];

           CRLF: Char;

       begin

           CRLF := 10;

           result := CSV.Split(CRLF);

           Exit(result);

       end;

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,553

#2
Sumit Singh Profile Picture

Sumit Singh 2,057

#3
YUN ZHU Profile Picture

YUN ZHU 1,915 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans