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.
2 Answers
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.
-
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
-
2If you're having problems with the logic I would suggest a new question to cover the specifics. Jul 29, 2013 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:
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);