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
1 Answer
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());
-
1Note: this is not the proper way to parse a CSV. It does not parse multi-line cells correctly.sfdcfox– sfdcfox2020-12-07 14:51:23 +00:00Commented Dec 7, 2020 at 14:51