Click here to Skip to main content
15,911,715 members
Home / Discussions / C#
   

C#

 
QuestionParsing text files Pin
alwaysthinking4-Feb-09 6:59
alwaysthinking4-Feb-09 6:59 
AnswerRe: Parsing text files Pin
musefan4-Feb-09 7:10
musefan4-Feb-09 7:10 
AnswerRe: Parsing text files Pin
PIEBALDconsult4-Feb-09 7:11
mvePIEBALDconsult4-Feb-09 7:11 
GeneralRe: Parsing text files Pin
alwaysthinking4-Feb-09 7:25
alwaysthinking4-Feb-09 7:25 
GeneralRe: Parsing text files Pin
alwaysthinking4-Feb-09 7:36
alwaysthinking4-Feb-09 7:36 
GeneralRe: Parsing text files Pin
Alan N4-Feb-09 7:46
Alan N4-Feb-09 7:46 
GeneralRe: Parsing text files Pin
PIEBALDconsult4-Feb-09 8:07
mvePIEBALDconsult4-Feb-09 8:07 
GeneralRe: Parsing text files Pin
PIEBALDconsult4-Feb-09 10:18
mvePIEBALDconsult4-Feb-09 10:18 
So far I've created this Regex:

System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex
(
    @"(?'Type'\S)\s(?'Time'\d\d:\d\d:\d\d)\sLine\s*(?'Line'[^:]*)\s:\s(?'Operation'[^\r]*)\r\n(?'Data'([^\r]*\r){1,3})"
,
    System.Text.RegularExpressions.RegexOptions.Compiled |
    System.Text.RegularExpressions.RegexOptions.Singleline |
    System.Text.RegularExpressions.RegexOptions.CultureInvariant
) ;


It matches the three log entries you provided and provides the named groups:

E 12:28:45 Line      1 : Dispense
- --------           -   --------
|       |            |         |
|       |            |         Operation
|       |            Line
|       Time
Type
 
and then the following two or three lines go into Data


You can then use the Operation to determine further processing of the Data, perhaps each operation would have its own Regex to parse its data.
GeneralRe: Parsing text files Pin
alwaysthinking9-Feb-09 8:35
alwaysthinking9-Feb-09 8:35 
GeneralRe: Parsing text files Pin
alwaysthinking9-Feb-09 8:36
alwaysthinking9-Feb-09 8:36 
GeneralRe: Parsing text files Pin
PIEBALDconsult9-Feb-09 11:59
mvePIEBALDconsult9-Feb-09 11:59 
GeneralRe: Parsing text files Pin
alwaysthinking10-Feb-09 10:01
alwaysthinking10-Feb-09 10:01 
GeneralRe: Parsing text files Pin
PIEBALDconsult10-Feb-09 12:08
mvePIEBALDconsult10-Feb-09 12:08 
GeneralRe: Parsing text files Pin
alwaysthinking17-Feb-09 12:22
alwaysthinking17-Feb-09 12:22 
GeneralRe: Parsing text files Pin
PIEBALDconsult17-Feb-09 12:28
mvePIEBALDconsult17-Feb-09 12:28 
GeneralRe: Parsing text files Pin
alwaysthinking17-Feb-09 12:32
alwaysthinking17-Feb-09 12:32 
GeneralRe: Parsing text files Pin
alwaysthinking17-Feb-09 12:53
alwaysthinking17-Feb-09 12:53 
GeneralRe: Parsing text files Pin
PIEBALDconsult17-Feb-09 13:21
mvePIEBALDconsult17-Feb-09 13:21 
GeneralRe: Parsing text files Pin
alwaysthinking17-Feb-09 13:32
alwaysthinking17-Feb-09 13:32 
GeneralRe: Parsing text files Pin
alwaysthinking17-Feb-09 13:42
alwaysthinking17-Feb-09 13:42 
QuestionWhich transform is faster/more effecient? Pin
Richard Blythe4-Feb-09 5:52
Richard Blythe4-Feb-09 5:52 
AnswerRe: Which transform is faster/more effecient? Pin
Mark Churchill4-Feb-09 14:03
Mark Churchill4-Feb-09 14:03 
GeneralRe: Which transform is faster/more effecient? Pin
Richard Blythe6-Feb-09 4:42
Richard Blythe6-Feb-09 4:42 
QuestionSimple DragDrop question Pin
Henry Minute4-Feb-09 5:17
Henry Minute4-Feb-09 5:17 
AnswerRe: Simple DragDrop question Pin
led mike4-Feb-09 6:04
led mike4-Feb-09 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.