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.

  • Can you clarify what exactly you're encountering? The implementation is not trivial, and there could be many stumbling blocks along the way. Please use gists or something to share you code as well, since that would be tremendously helpful. – Marty C. Dec 18 '14 at 20:53

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.

| improve this answer | |
  • I have corrected it. Now that error is not coming. But still unable to implement the logic. need help. Does anyone have code of a working model where 'Importing CSV files by batch apex' is implemented. – LoveSalesforce Jul 29 '13 at 10:10
  • 2
    If you're having problems with the logic I would suggest a new question to cover the specifics. – Mike Chale Jul 29 '13 at 10:24

Try this ImportCSVJob class as a reference implementation of Database.Batchable and 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:

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);
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.