+ 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.

Thanks,
  Vishnu
@GM@GM
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.

Regards,
GM


 
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.
https://www.forcetalks.com/blog/automate-salesforce-data-import-export-using-data-loader-cli
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?

Thanks,
  Vishnu
@GM@GM
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