Multi Value Separator with .net C#
Asked Answered
E

1

8

When we use C# with the Universe database the multi values are coming from the Universe Database as comma separated values to the programming site. Normally in Pick Basic language programming they come up as a ^252 or ^253 separated values. Therefore we can split the multi value easily with value separators because people don’t use the ^252 or ^253 in normal data entries.

But in C# when we select multi values from the Universe database they comes up with comma separated. If the multi value data actually contains a comma then we can’t use the comma value(,) as a value separator. Because this will split the multi value data in the wrong position.

For example if the multi value data is :

01 Although , we will do , Tom goes there , I will come down

The multi value for the above record are separated by a comma in the .net programming. But the first value(in bold) actually contains a comma after the “Although”.

We are facing problem to use the C# Split function to separate the data and get the individual values. Could you tell us how can we can overcome this in C# orVB.net programming with Universe database and get the individual values/sub values? .

Thank you.

Embolden answered 16/10, 2013 at 2:4 Comment(8)
+1 .. very good question as this is a very difficult problem. Are you able to put the token in double quotes. Such as: 01 "Although , we will do" , Tom goes there , I will come downRoily
Perhaps you could store every comma in your entries with its unicode value U+002C and change it back after retrieving everything?Biddie
Check out how comma is handled in CSV, also it feels really bad idea to return data from DB in CSV format rather than list of values or name/value pairs.Known
Agree with @Alexei-Levenkov: you should be able to rewrite the C# code to return data as a structured collection instead of comma-separated strings. Perhaps you could post your code?Lune
We need more information. The native connectors for that database won't return the delimiters as comma's, so what is changing them in your case? Do you have control over that piece? You will need to if you want to solve this, unless you can encode the data before-hand to escape the commas.War
The code example which reads data from your database is needed here.Seda
As others have said, it will really help if you show us the code that you are using right now.Mam
Can a comma only occure in the bold block or also in the "Tom goes there" and "I will come down" block? If not you could seperate by the first and the last two commas and all other commas would be part of the (in this case) bold part.Fung
N
2

In general field delimiters are required precisely for the problem you are describing. If you use " you will then also need to decide what to do when your data inside a field also holds a " in it.

When you have found a good field delimiter (one with small memory foot print and that your data is not likely to contain). You can create a regular expression to grab the data from each field.

Like others have said, some code snippets or samples will mean that answers are more accurate and helpful.

Is there anyway you can bring the data back into a specific Type, for example MS DataTable or your own structure? List, where Row is a Type you create to store all possible fields in your specific data model?

Nathalie answered 24/10, 2013 at 10:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.