You need to sign in to do that
Don't have an account?
Zachariah Rosenberg
Accessing CSV data in developer console
I'm trying to use CSV data in an apex class. There are many articles written about how to parse csv data in apex, but not many on the first part: accessing the csv data in apex. I've looked into import wizard (and data loader) but my csv data is not being uploaded into any sobjects. Rather, the csv data will be used for a SOQL query.
Ultimately I'd like the following query to be able to use my csv data:
SELECT Object.Name Object.custom_field__c FROM Object WHERE custom_field__c in :[csv data]
How can I make this happen?
Thank you so much!
Ultimately I'd like the following query to be able to use my csv data:
SELECT Object.Name Object.custom_field__c FROM Object WHERE custom_field__c in :[csv data]
How can I make this happen?
Thank you so much!
Your CSV file can be uploaded as an attachment, document, or just uploaded directly into a visualforce page by the user. At that point the controller can access the csv file as a string, use split('\n') and split(','), and get those values out.
Something like
CSV Parser (https://developer.salesforce.com/page/Code_Samples#Parse_a_CSV_with_APEX) -> List<String>
http://www.sfdcpoint.com/salesforce/import-csv-file-using-apex-visualforce/
You should combine it with Kevin's suggestion through because his link has a more comprehensive csv parser.