House numbers in KLADR, C# and T-SQL

0 like 0 dislike
7 views
Dear Gabrieli. I have here a question.

I need to rebuild KLADR (all-Russian classifier of addresses) in a digestible hierarchical structure. After a sleepless night, fifty cigarettes and a bucket of coffee you only have to parse the rows in the table HOME.

As you know, in the database KLADR the names of the houses are kept roughly in this format:

N(19-31), N(67-77), H(2-40),65

or

4k1,4к2,4к3,6к1,6к2,8к1стр3,8к2,10.

How, using C# and T-SQL, you can Preobrazovatel these lines just in the list of buildings, structures, enclosures and so on in order? I understand that here it is possible to use regular expressions, but I, alas, they are not strong.
by | 7 views

1 Answer

0 like 0 dislike
would that be suitable?
\r
// Pass the Value as a string c list of buildings from the table KA_DOMA private List HousDecode(string value) { List tempCollection = new List(); // Pars 'encrypt' homes for street string[] tmp1 = value.Split(','); foreach (string txt in tmp1) { if (txt.ToUpper().IndexOf('H') != -1 || txt.ToUpper().IndexOf('N') != -1) { string tmptxt = txt.Replace(")", ""); string[] v = (tmptxt.Split('(')[1]).Split('-'); int v1 = Convert.ToInt32(v[0]); int v2 = Convert.ToInt32(v[1]); for (int i = v1; i <= v2; i = i + 2) { tempCollection.Add(i.ToString().Trim()); } continue; } if (txt.ToUpper().IndexOf('-') != -1) { string[] v = txt.Split('-'); int v1 = Convert.ToInt32(v[0]); int v2 = Convert.ToInt32(v[1]); for (int i = v1; i <= v2; i++) { tempCollection.Add(i.ToString().Trim()); } continue; } tempCollection.Add(txt.Trim()); } return tempCollection; } 
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Mar 24, 2019 by sergpenza
0 like 0 dislike
7 answers
asked Mar 26, 2019 by GreyKnight
0 like 0 dislike
1 answer
asked May 4, 2019 by Maximka123
110,608 questions
257,186 answers
0 comments
28,874 users