Home > Back-end >  Text file analysis
Text file analysis

Time:09-21

A log file monitoring software, the content is as follows:

Date/time interface equipment state

The 2016-09-01 08:00 J1 D1 Down

The 2016-09-01 08:15 J2 D2 Down

The 2016-09-01 08:26 J1 D1 Up

The 2016-09-01 GMT J2 D2 Up

.

Now need to analyze the log file by the program, get the following contents:

Date time to recover time interface equipment

The 2016-09-01 08:00 08:26 J1 D1

The 2016-09-01 08:18 09:00 J2 D2

.

This what to do???

CodePudding user response:

You are so specification this data
Create a TextFile
Loading text document
Analysis of string in the database (copy command truncated string)
Database filter

CodePudding user response:

Key point is to design a structure to save the result,
Such as use a TStringList + TResult,
This TResult is your design class, the class contains interface, equipment, date, start time, end time attributes, such as

The next line analysis, storing the results of the analysis to the TStringList + TResult,

Finally, taking out TStringList + TResult results, forming the format you want,

CodePudding user response:

reference 1st floor jjpweb response:
you this data very specification
Create a TextFile
Loading text document
Analysis of string in the database (copy command truncated string)
Database filter

Mainly there are a lot of records, and the same number of equipment failure, so I don't know how to operate,

CodePudding user response:

refer to the second floor Frank6600 response:
key point is to design a structure to save the result,
Such as use a TStringList + TResult,
This TResult is your design class, the class contains interface, equipment, date, start time, end time attributes, such as

The next line analysis, storing the results of the analysis to the TStringList + TResult,

Finally, taking out TStringList + TResult results, the formation of the format you want to

I am now defines a record, the first record is assigned to a variable, and then starting from the second analysis, if the second interface, the device is the same as the first, and the status of the up, set the end of the first time to the beginning of the second time, but just don't know the zha a got behind

CodePudding user response:

reference 4 floor liujun3888358 response:
Quote: refer to the second floor Frank6600 response:
key point is to design a structure to save the result,
Such as use a TStringList + TResult,
This TResult is your design class, the class contains interface, equipment, date, start time, end time attributes, such as

The next line analysis, storing the results of the analysis to the TStringList + TResult,

Finally, taking out TStringList + TResult results, the formation of the format you want to

I am now defines a record, the first record is assigned to a variable, and then starting from the second analysis, if the second interface, the device is the same as the first, and the status of the up, set the end of the first time to the beginning of the second time, but just don't know the zha a got behind


Record and you said I said TResult is almost the same meaning,
But I also added a TStringList to manage multiple TResult,
So can handle n data,

TStringList TResult can save one by one,
Each judge which one is from equipment + interface TResult to the processing of you already know, so can,
  • Related