diff --git a/custom_md_loader/classes/CSVFileUtil.cls b/custom_md_loader/classes/CSVFileUtil.cls index d99cbd5..843ec2f 100644 --- a/custom_md_loader/classes/CSVFileUtil.cls +++ b/custom_md_loader/classes/CSVFileUtil.cls @@ -42,7 +42,10 @@ public class CSVFileUtil { // check for blank CSV lines (only commas) if (line.replaceAll(',','').trim().length() == 0) break; - List fields = line.split(','); + // -1 in the split method will not remove empty values at the end in the result list. + // For example, if a csv file line has A,B,, -> The result of this split would be + // ['A', 'B', '', '']. Withouth -1 in the method it would be ['A', 'B'] + List fields = line.split(',', -1); List cleanFields = new List(); String compositeField; Boolean makeCompositeField = false;