Answer the question
In order to leave comments, you need to log in
House numbers in KLADR, C# and T-SQL
Dear cheaters. I have a question.
I need to rebuild KLADR (all-Russian address classifier) into a digestible hierarchical structure. After a sleepless night, fifty cigarettes and a bucket of coffee, all that was left was to parse rows in the DOMA table.
As you know, in the KLADR database, the names of houses are stored approximately in the following format:
H (19-31), H (67-77), H (2-40), 65
or
4k1.4k2.4k3.6k1.6k2. 8k2,10.
How, using C# and T-SQL, can these strings be converted simply into a list of houses, buildings, buildings, and so on in order? I understand that regular expressions can be used here, but, alas, I am not strong in them.
Answer the question
In order to leave comments, you need to log in
so fit?
// Передаем в качестве Value - строку c перечнем зданий из таблицы KA_DOMA
private List<string> HousDecode(string value)
{
List<string> tempCollection = new List<string>();
// Парс 'шифровки' домов для улицы
string[] tmp1 = value.Split(',');
foreach (string txt in tmp1)
{
if (txt.ToUpper().IndexOf('Ч') != -1 || txt.ToUpper().IndexOf('Н') != -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;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question