这是需要处理的文本文件的摘录。需要完成的是程序 必须在这个文本文件中读取并将其格式化为一个规范。问题是我没有太多的工作 与文本文件的体验。这是示例输入文件。在C#中将文本文件读入数组中
BSA Security Definition - Operator Report Type 28
NBC 3RD QUARTER PROFILE REVIEW 2010
________________________________________________________________________________
Operator: ABAZ095
Number of entries: 149
User selection: Selected Items
________________________________________________________________________________
Search Criteria :-
Operator Name = BT%
Approval Status = Any
Enable Status = Any
One-time Pwd = Any
Profiles =
Units =
Printers =
Terminals =
________________________________________________________________________________
Operator ID = BTA020
Name = ASIA CHAMBEGA
Active profile = User_Disabled
Enable status = Disabled
Re-enable date = 31/12/36 00:00:00
Approval status = Approved
Last changed = 21/07/10 07:34:30
Last sign-on = 13/06/08 14:09:37
Calculated pwd = BD
One-time password = No
Assigned unit = None
Operator ID = BTAC002
Name = A KALATA (NBC)
Active profile = User_Disabled
Enable status = Disabled
Re-enable date = 31/12/36 00:00:00
Approval status = Approved
Last changed = 31/05/10 14:04:41
Last sign-on = n/a
Calculated pwd = B9
One-time password = No
Assigned unit = None
Operator ID = BTAK000
Name = AISHA KEJO
Active profile = NLCB_R6.0_ACCESSCTRL
Active profile = NLCB_R6.0_VERAUT_MBE
Enable status = Enabled
Re-enable date = n/a
Approval status = Approved
Last changed = 12/07/08 08:10:47
Last sign-on = 19/07/08 08:08:58
Calculated pwd = 8A
One-time password = No
Assigned unit = NLCB
Operator ID = BTAL001
Name = AMANDUS LIPILI
Active profile = User_Disabled
Enable status = Disabled
Re-enable date = 31/12/36 00:00:00
Approval status = Approved
Last changed = 01/07/10 08:39:03
Last sign-on = 11/11/09 08:25:07
Calculated pwd = 4B
One-time password = No
Assigned unit = None
当处理的输出文件应如下所示:
BTAK000, AISHA KEJO, NLCB_R6.0_ACCESSCTRL
BTAK000, AISHA KEJO, NLCB_R6.0_VERAUT_MBE
正如你所看到的,所需要的一切数据,但只有运营商ID,姓名和活动的配置文件需要输出被拉。 如果在文件中找到每个操作员标识,则结果需要打印到新行。如果用户有超过1 活动配置文件,则必须将操作员标识和名称和配置文件输出到新行。如果用户具有禁用的配置文件 ,则必须忽略数据。正如您从示例中所看到的,第一个单元被忽略,因为它们被禁用。具有启用satatus的 用户就是例子。正如你可以看到的输出示例。
我的想法是将数据拉到数组中,但只输出操作员ID,名称和配置文件。我该怎么做呢?
这是我到目前为止有:
Console.WriteLine("Enter Input File Location: " + "\n");
//Reads path specifed by the user for input.
string t = File.ReadAllText(Console.ReadLine());
//Splits file where there is an equals sign.
t = t.Replace("=", "");
//Removes all tabbed spaces.
t = t.Replace("\t", "");
//Removes any new lines.
t = t.Replace("\n", ",");
//Removes blank spaces.
t = t.Replace(" ", "");
//Removes the Underscore.
t = t.Replace("_", "");
//Removes any leading or trailing whitespaces.
t = t.Trim(',');
//Writes formatted file to a pre defined ouput file's location.
File.WriteAllText(@"C:/3rd Quarter1.txt", t);
请张贴鳕鱼e迄今为止你写的。人们通常不喜欢只为你写代码。事实上,这是一个工作描述,而不是一个问题。 – 2011-02-27 11:45:01
没有人会为你做你的工作。试一试,回来**具体的**编程问题。例如:“我如何从文本文件中读取信息”或“如何将此文本行分隔为多个部分,使用冒号作为分隔符” – jgauffin 2011-02-27 11:48:25
好的,我在这里有代码。它所做的基本上是拆分,删除等号并对文本进行格式化,以便它从新行开始,即时遇到问题的是我不知道如何有选择地选择要输出的信息。继承人迄今为止:见编辑quaeston – Paveetren 2011-02-27 12:08:24