0

From internet found this article and found usefull, but I am seeing it will give only first line of the line, how to parse the file and get all the lines in a list. Below is the link which @eric has wrote/answered Catch Regex too complicated when splitting a string in salesforce

0

1 Answer 1

0

In @Eric answer here , he has used if condition, try to use while in your case and that should iterate the whole file.

NOTE : I have not tried this.

UPDATE:

Just tried it and while works fine.

List<ContentVersion> contentVersion = [
        SELECT
                VersionData
        FROM ContentVersion
        WHERE ContentDocumentId = '*********'
];


Utility_RowIterator r = new Utility_RowIterator(contentVersion.get(0).VersionData.toString(), '\n'); //Replace \n with whatever delineates your row

List<String> allRow = new List<String>();
while (r.hasNext()) {
    allRow.add(r.next());
}

System.debug(allRow.size());
1
  • 1
    Note: this is not the proper way to parse a CSV. It does not parse multi-line cells correctly. Commented Dec 7, 2020 at 14:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.