none
Removing double quotes from the string array RRS feed

  • Question

  • I am developing application that will convert csv files to xml files but the problem is with the input xml files,

    Csv files : "a" ,"b","c"

    Xml file : <A>"a"</A>

                   <B>"b"</B>

    ------

     

    Question : I am using string array for getting input csv files . How do we remove the "" from the string array? 

     

    Monday, January 9, 2012 6:28 AM

Answers

  • Hi,

    you can use the .Trim() method of the String class like:


    'Visual Basic 2008 - .net 3.5 - Any CPU
            Dim myStringArray As String() = {"""a""", """b"""}
            Dim trimCharArray As Char() = New Char() {""""c}
            For Each s As String In myStringArray
                s = s.Trim(trimCharArray)
            Next
    

     


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Proposed as answer by Adavesh Monday, January 9, 2012 6:50 AM
    • Marked as answer by Paul Zhou Tuesday, January 17, 2012 8:55 AM
    Monday, January 9, 2012 6:42 AM
  • hii try this,

    it may usefull for you

      string asda = @"<A>""a""</A>";
                var x=asda.Split('"');
                var xa = String.Join("", x);
    



    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by san Sanz Monday, January 9, 2012 6:49 AM
    • Marked as answer by Paul Zhou Tuesday, January 17, 2012 8:55 AM
    Monday, January 9, 2012 6:49 AM
  • Hi,

    Try using it this way..

     strCSV.Replace('"',' ');
                string[] stringArray = strCSV.Trim().Split(',');
    


    WHERE strCSV is your string from csv file.

    Hope this helps.

    Thanks!


    Every day its a new learning. Keep Learning!!
    If this post answers your question, please click Mark As Answer . If this post is helpful please click Mark as Helpful
    • Marked as answer by Paul Zhou Tuesday, January 17, 2012 8:55 AM
    Monday, January 9, 2012 6:52 AM

All replies

  • Hi,

    you can use the .Trim() method of the String class like:


    'Visual Basic 2008 - .net 3.5 - Any CPU
            Dim myStringArray As String() = {"""a""", """b"""}
            Dim trimCharArray As Char() = New Char() {""""c}
            For Each s As String In myStringArray
                s = s.Trim(trimCharArray)
            Next
    

     


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Proposed as answer by Adavesh Monday, January 9, 2012 6:50 AM
    • Marked as answer by Paul Zhou Tuesday, January 17, 2012 8:55 AM
    Monday, January 9, 2012 6:42 AM
  • hii try this,

    it may usefull for you

      string asda = @"<A>""a""</A>";
                var x=asda.Split('"');
                var xa = String.Join("", x);
    



    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by san Sanz Monday, January 9, 2012 6:49 AM
    • Marked as answer by Paul Zhou Tuesday, January 17, 2012 8:55 AM
    Monday, January 9, 2012 6:49 AM
  • Hi,

    Try using it this way..

     strCSV.Replace('"',' ');
                string[] stringArray = strCSV.Trim().Split(',');
    


    WHERE strCSV is your string from csv file.

    Hope this helps.

    Thanks!


    Every day its a new learning. Keep Learning!!
    If this post answers your question, please click Mark As Answer . If this post is helpful please click Mark as Helpful
    • Marked as answer by Paul Zhou Tuesday, January 17, 2012 8:55 AM
    Monday, January 9, 2012 6:52 AM
  • Use a CSV library, such as this one.  There are a good many subtleties to CSV files - if you try to parse it yourself, you may be in for a long line of CSV files that are just not quite what your code was expecting.
    -cd Mark the best replies as answers!
    Tuesday, January 10, 2012 1:40 AM
    Moderator