Показать сообщение отдельно
Тема: Кто шарит в экселе помогите | by @Gudron
Непрочитано 10.12.2009, 15:27   # 4
3.2%
 
Аватар для Kефир
 
Регистрация: 01.08.2005
Адрес: Ленинград
Возраст: 38
Сообщений: 7,935
Записей в дневнике: 1
Байк: Старый Притон
Отправить сообщение для Kефир с помощью ICQ
Kефир вне форума
Я сделал уже. Не парься.

Код:
using System.Collections.Generic;
using System.IO;
using System.Text;


namespace ConsoleApplication6
{
   internal class Program
   {
      private static void Main(string[] args)
      {
         string[] lines = File.ReadAllLines("c:\\temp\\gudron.csv", Encoding.GetEncoding(1251));
         var col1 = new List<string>();
         var col2 = new List<string>();
         var result = new List<string>();

         foreach (string line in lines)
         {
            string[] ss = line.Split(';');
            col1.Add(ss[1]);
            col2.Add(ss[3]);
         }

         foreach (string s in col1)
         {
            if (string.IsNullOrEmpty(s))
               continue;

            string match = col2.Find(x => x.Contains(s));
            result.Add(string.IsNullOrEmpty(match) ? s : match);
         }

         File.WriteAllLines("c:\\temp\\gudron_result.csv", result.ToArray(), Encoding.GetEncoding(1251));
      }

   }
}}
Цитата