我嘗試了略有不同的方法。我創建了一個控制檯程序,可以將這些文件轉換爲完全限定的csv文件。然後你可以很容易地使用ssms導入到sql。
static void Main(string[] args)
{
if (args.Length == 2)
{
using (StreamWriter sw = new StreamWriter(args[1]))
{
using (StreamReader sr = new StreamReader(args[0]))
{
String line;
while ((line = sr.ReadLine()) != null)
{
int index = 0;
int oldIndex = 0;
string dateTime = null;
string action = null;
string task = null;
string details = null;
index = line.IndexOf(' ', oldIndex);
dateTime = line.Substring(oldIndex, index - oldIndex);
oldIndex = index + 1;
index = line.IndexOf(' ', oldIndex);
action = line.Substring(oldIndex, index - oldIndex);
oldIndex = index + 1;
index = line.IndexOf(':', oldIndex);
task = line.Substring(oldIndex, index - oldIndex);
oldIndex = index + 1;
details = line.Substring(oldIndex + 1);
sw.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\"", dateTime, action, task, details);
}
}
}
}
else
{
Console.WriteLine("Usage: program <input> <output>");
}
}
只是說明一下,並不是所有的線都看起來像這三個。 「I」是不同的字母,「搜索」和「請求」是不同的。 – 2013-02-15 23:06:33
是文字「我搜索:xx ~~~在每一行嗎?或者它只是爲了演示嗎?」 – XtrmJosh 2013-02-15 23:09:02