2

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.

1
  • 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, 2014 at 20:53

2 Answers 2

5

The problem is that you are trying to reference a static variable incorrectly.

Change

return new CSVIterator(m_csvFile, m_parser.crlf);

to

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.

2
  • 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. Jul 29, 2013 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, 2013 at 10:24
5

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:

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);

Not the answer you're looking for? Browse other questions tagged .