function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
G_NG_N 

How to read a CSV file using Apex/Visual force

Hi,

I want to read a CSV file using Apex/Visualforce. Can we read a CSV file using Apex/Visual force? Any code sample would be helpful.

 

 

Thanks in advance!!!

 

Thanks,

NG

Best Answer chosen by Admin (Salesforce Developers) 
Kirtesh_JainKirtesh_Jain

Hi ,

 

 Hi ,

 

you can use this type of tag on VF page

 

<apex:inputFile value="{!contentFile}" filename="{!nameFile}" />

 

contentFile will be property of blob type.

 

you can parse by contentFile.tostring() . It will give you whole string of CSV file.

then use split method of Apex string object .

 

If you are still have a problem, then contact on kodiyakirti123@gmail.com

 

 

Thanks,

Kirtesh Jain

 

 

All Answers

Kirtesh_JainKirtesh_Jain

Hi ,

 

 Hi ,

 

you can use this type of tag on VF page

 

<apex:inputFile value="{!contentFile}" filename="{!nameFile}" />

 

contentFile will be property of blob type.

 

you can parse by contentFile.tostring() . It will give you whole string of CSV file.

then use split method of Apex string object .

 

If you are still have a problem, then contact on kodiyakirti123@gmail.com

 

 

Thanks,

Kirtesh Jain

 

 

This was selected as the best answer
miteshsuramiteshsura

how can I read a csv via apex? the usage is , user will store the file in documents folder and my apex code should periodically check for new files in that folder. And if found, process it. 

 

The csv file is nothing but product master file, that I receive from other system. 

 

thanks in advance..

Nazeer AhamedNazeer Ahamed

Hi Mitesh, 

 

Have you successful on implementing the approach you described, I am also looking for samething. Pls share your experience. thx.

miteshsuramiteshsura

no not yet .. I come from asp.net background, and they have very well documented the things. I am sure this must be true for any other platform too. 

 

But when it comes to force.com, we are always hunting for the solution?? I wish they had well documented. ..