+ Start a Discussion
raju123raju123 

How to Handle LineBreaks and commas in CSV file while Importing through visualforce

Hi,

 

       

          I am trying to import data through CSV from visualforce page. Its working well. But when CSV file contains Iine breaks in one Field then  i can't able to handle it. Getting error as System.ListException: List index out of bounds: 6 

 

 

 

Even Iam getting Problem with comma in any of the field

 

 

Please can one help me on this

 

 

Thanks

SRKSRK

can u share a code it will be more help full

Richie DRichie D

Hi,

 

Try surrounding each entry with "s so you have 

 

"abc","def","ghi"

"ab,c","def","g,hi"
"ab
c","d,e,f",ghi"
If this doesn't work then try 's. You will need to escape any " or ' in your data.
 
Rich
SRKSRK

ok

hear what i try in systemlog & it's working

String temp = '"abc","def","ghi"';

 

system.debug('$$$$$$$$$$$$$$$$$'+temp.replace('\'',''));   repalce '

 

system.debug('$$$$$$$$$$$$$$$$$'+temp.replace('"',''));   // repalce "