+ Start a Discussion
Vishnu Prasad 18Vishnu Prasad 18 

scheduling daily job to import data from csv

Hi Team,

I have a requirement to import data into some particular objects from CSV which are placed at particular path at particular time.

Request you to kindly help in that.

you can use a Visualforce apex:inputFile to upload the file and then apply this parse CSV with Apex sample code to grab the data from the rows.
Link : https://developer.salesforce.com/page/Code_Samples#Parse_a_CSV_with_APEX (https://developer.salesforce.com/page/Code_Samples#Parse_a_CSV_with_APEX)
If the CSV files are large you will hit a governor limit such as the the 6M byte heap space or the 10 seconds of CPU or the 10,000 rows of DML.


Dmitry OfitserovDmitry Ofitserov
Hi Vishnu,
Consider using Data Loader CLI for this purpose. Thus you can schedule data import times and can import data from multiple CSVs into multiple object. You will not have CPU, HEAP or DML limitations on it.
Vishnu Prasad 18Vishnu Prasad 18
Hi @GM

We cannot use VF page as file is placed in shared path. So need to somehow pick it from there. 

@ Dmitry Ofitserov

Thank you very much for quick reply. Is there any way to use Batch Apex and Batch script to automate it other than using CLI?

You have to use CLI to automate it as Dmitry Ofitserov mentioned. You can't use batch to automate it since batch works inside salesforce org context. It can't pick file from shared path. Regards, GM