Split(row, ",") when some values contain comma

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Split(row, ",") when some values contain comma

    Hi All,

    I have a few CSV files and their content is like this:

    "1","ABC","DEF,GHI","FGH"

    You can notice that a cell contains the value "DEF,GHI" with a comma

    I would like to split this row into values. If I use Split(row,",") then the
    above value will be splited into "DEF" and "GHI" and I don't want this. How
    can I split the row into correct values?

    Regards,
    Nicolae




    Nicolae Fieraru Guest

  2. Similar Questions and Discussions

    1. Reading values from menubar dataProvider for "top" menuitems
      I have a XML file that looks like this: <?xml version="1.0" encoding="ISO-8859-1" ?> <root> <menuitem label="Home" value="2" /> <menuitem...
    2. Passing "invisible" values for site flow
      I have a login screen that takes an email address as the username and then a password. This user/pass combo is stored in a database. I've written...
    3. Problem with DataGrid and values that are empty when AutoGenerateColumns="False"
      Hi! Im currently writing my Master Thesis in Computer Science and i have get caught in a strange DataGrid problem. Im using a DataGrid with 4...
    4. Make text boxes "forget" values
      Hi Jonathan! I believe that the IsPostBack property is what you're looking for. You can add code to the page_load event that looks something...
    5. Specifying "do not update" values in "additive" UPDATE sprocs
      Hello, I want to write a sproc whose purpose is to perform 'additive' UPDATEs to a given table. By 'additive', I mean I would like the existing...
  3. #2

    Default Re: Split(row, ",") when some values contain comma

    You could split on "," instead of just ,

    Split(row, Chr(34) & "," & Chr(34))

    Then handle the leading " for the first array element, and trailing " for
    the last array element.

    --
    Manohar Kamath
    Editor, .netBooks
    [url]www.dotnetbooks.com[/url]


    "Nicolae Fieraru" <nospam@please.com> wrote in message
    news:%23zMRL8ncDHA.616@TK2MSFTNGP11.phx.gbl...
    > Hi All,
    >
    > I have a few CSV files and their content is like this:
    >
    > "1","ABC","DEF,GHI","FGH"
    >
    > You can notice that a cell contains the value "DEF,GHI" with a comma
    >
    > I would like to split this row into values. If I use Split(row,",") then
    the
    > above value will be splited into "DEF" and "GHI" and I don't want this.
    How
    > can I split the row into correct values?
    >
    > Regards,
    > Nicolae
    >
    >
    >
    >

    Manohar Kamath [MVP] Guest

  4. #3

    Default Re: Split(row, ",") when some values contain comma

    Hi Manohar,

    Thank you very much for your tip, I already found an earlier message of
    yours and it helped me.

    Regards,
    Nicolae


    "Manohar Kamath [MVP]" <mkamath@TAKETHISOUTkamath.com> wrote in message
    news:#gb5IgocDHA.2672@tk2msftngp13.phx.gbl...
    > You could split on "," instead of just ,
    >
    > Split(row, Chr(34) & "," & Chr(34))
    >
    > Then handle the leading " for the first array element, and trailing " for
    > the last array element.
    >
    > --
    > Manohar Kamath
    > Editor, .netBooks
    > [url]www.dotnetbooks.com[/url]
    >
    >
    > "Nicolae Fieraru" <nospam@please.com> wrote in message
    > news:%23zMRL8ncDHA.616@TK2MSFTNGP11.phx.gbl...
    > > Hi All,
    > >
    > > I have a few CSV files and their content is like this:
    > >
    > > "1","ABC","DEF,GHI","FGH"
    > >
    > > You can notice that a cell contains the value "DEF,GHI" with a comma
    > >
    > > I would like to split this row into values. If I use Split(row,",") then
    > the
    > > above value will be splited into "DEF" and "GHI" and I don't want this.
    > How
    > > can I split the row into correct values?
    > >
    > > Regards,
    > > Nicolae
    > >
    > >
    > >
    > >
    >
    >

    Nicolae Fieraru Guest

  5. #4

    Default Re: Split(row, ",") when some values contain comma

    What if it's not "several values" but a piece of text that happens to
    contain a comma?

    Cheers
    Ken


    "Harag" <harag@softhome.net> wrote in message
    news:4judlvg0vi0ti6qcsqhfk7u44m1qt6nki4@4ax.com...
    : what I normally do when I store several values in one field is to use
    : a PIPE character "|"
    :
    : eg:
    : "1","ABC","DEF|GHI","FGH"
    :
    : HTH
    : Al.
    :
    : On Thu, 4 Sep 2003 10:55:08 +1000, "Nicolae Fieraru"
    : <nospam@please.com> wrote:
    :
    : >Hi All,
    : >
    : >I have a few CSV files and their content is like this:
    : >
    : >"1","ABC","DEF,GHI","FGH"
    : >
    : >You can notice that a cell contains the value "DEF,GHI" with a comma
    : >
    : >I would like to split this row into values. If I use Split(row,",") then
    the
    : >above value will be splited into "DEF" and "GHI" and I don't want this.
    How
    : >can I split the row into correct values?
    : >
    : >Regards,
    : >Nicolae
    : >
    : >
    : >
    :


    Ken Schaefer Guest

  6. #5

    Default Re: Split(row, ",") when some values contain comma

    In news:jikelvgl2pte5d3a88ctfkrvm8k1lhv4v3@4ax.com,
    Harag <harag@softhome.net> typed:
    : Yeah thats the problem. It does really depend what the developer is
    : going to store. I was just giving them something else to think about
    : :) since the "|" (pipe) character is not used when typing normal text.

    However the *standard* comma separate values (CSV) file allows quoted text
    to contain commas (the delimiter). So unless you're going to change all
    those applications (including Excel, etc.) the OP will have to deal with it.

    However, I understand your point also, when I have a choice I use tabs to
    separate field values. It wasn't a criticism, just pointing out the fact
    that the OP may not have control of the application producting the CSV file
    and the CSV is in a standard format.

    Don Verhagen


    : It was kind of you to point this out as I did forget to mention it
    : earlier :)
    :
    : thanks.
    : Al
    :
    : On Thu, 4 Sep 2003 20:49:19 +1000, "Ken Schaefer"
    : <kenREMOVE@THISadOpenStatic.com> wrote:
    :
    :: What if it's not "several values" but a piece of text that happens to
    :: contain a comma?
    ::
    :: Cheers
    :: Ken
    ::
    ::
    :: "Harag" <harag@softhome.net> wrote in message
    :: news:4judlvg0vi0ti6qcsqhfk7u44m1qt6nki4@4ax.com...
    ::: what I normally do when I store several values in one field is to
    ::: use
    ::: a PIPE character "|"
    :::
    ::: eg:
    ::: "1","ABC","DEF|GHI","FGH"
    :::
    ::: HTH
    ::: Al.
    :::
    ::: On Thu, 4 Sep 2003 10:55:08 +1000, "Nicolae Fieraru"
    ::: <nospam@please.com> wrote:
    :::
    :::: Hi All,
    ::::
    :::: I have a few CSV files and their content is like this:
    ::::
    :::: "1","ABC","DEF,GHI","FGH"
    ::::
    :::: You can notice that a cell contains the value "DEF,GHI" with a
    :::: comma
    ::::
    :::: I would like to split this row into values. If I use
    :::: Split(row,",") then the above value will be splited into "DEF" and
    :::: "GHI" and I don't want this. How can I split the row into correct
    :::: values?
    ::::
    :::: Regards,
    :::: Nicolae


    Don Verhagen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139