Skip to content

Instantly share code, notes, and snippets.

@dancinllama
Created August 9, 2012 16:17
Show Gist options
  • Save dancinllama/3305582 to your computer and use it in GitHub Desktop.
Save dancinllama/3305582 to your computer and use it in GitHub Desktop.
private Map<String,Set<String>> parseCsv(Integer numRecords){
//csvFile is public Blob member variable...
String csvData = csvFile.ToString();
csvData = csvData.replace('"','');
List<String> records = csvData.split('\r?\n');
Map<String,Set<String>> ans = ...
//Start at 1 to skip header row
for(Integer i=1; i < records.size() && (numRecords == null || i <= numRecords); i++){
String [] columns = records.get(i).split(',',-1);
String accountNum = columns[0];
String name = columns[1];
String eligible = columns[2];
String reason = columns[3];
//Do other stuff
}
return ans;
}
Col1,Col2,Col3,Col4^MVal1,Val2,Val3,Val4^MVal5,Val6,Val7,Val8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment