locked
how to use encapsulation while reading csv file. RRS feed

  • Question

  • User1119325357 posted

    How to read csv file using delimiters and encapsulation or encloser, escaper in asp.net vb.net

    or how to use encapsulation while reading csv file.

    for eg. following is a sample csv file data.

    Salutation,FirstName,LastName,Address1,Address2
    Ms, Shruti,Nene , 2520 Renuka Soc.,Suite 100,Pune
    Dr.,Manali,Desarda, "2520, Renaissance Blvd","Suite, 100"

    here in second row there is encapsulation used as " " and in between there is delimiter used as ','. so while reading that column field value we

    need to skip the delimiters used in encapsulation and used whole text within  " " encapsulation as single column field value.

    Friday, June 3, 2011 7:19 AM

Answers

  • User-125547262 posted

    Why not split it by the , and then replace the quotes if there are any? In fact if you search on the web.. you will find some examples

    http://www.stellman-greene.com/CSVReader/

    http://www.dotnetspider.com/qa/Question4942.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 3, 2011 8:27 AM