I need help for Importing large CSV files via Batch Apex. I have tried this link => http://developer.financialforce.com/customizations/importing-large-csv-files-via-batch-apex/ .But unable to implement it.Please help.
closed as off-topic by Adrian Larson♦, Keith C, Eric, Boris Bachovski, metadaddy Oct 28 '15 at 0:25
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Adrian Larson, Keith C, Eric, Boris Bachovski, metadaddy
The problem is that you are trying to reference a static variable incorrectly.
return new CSVIterator(m_csvFile, m_parser.crlf);
return new CSVIterator(m_csvFile, Parser.crlf);
When you want to reference a static member you prefix it with the class name and do not use an instance of the class.
Try this ImportCSVJob class as a reference implementation of
Schedulable. The class demonstrates how you can use CSVReader to read CSV data, construct new records and then insert those records.
Try testing your job with the simple Lead-import.csv data below:
FirstName,LastName,Company Marty,Chang,Slalom Consulting Homer,Simpson,Springfield Nuclear Power Plant
You can schedule the job or run the job using the Developer Console to execute the following as anonymous Apex:
Database.executeBatch(new ImportCSVJob(), 1);