pete_agreatguy
New Member
Hi all,
I would like to find a way of automating "getting" certain data from a log.txt file as doing this manually via notepad++ is extremely tedious - let alone time consuming.
Any help would be highly appreciated in getting this automated at the click of a button within Excel, assuming it is feasible?
Please note that even though I have had some programming experience in the past (2003) I am not so confident in myself so please treat me as such. I also suffer mental health and my concentration is poor at the moment. i.e. Please be kind. Thank you.
The data I would like to find within a text file to transfer into an Excel worksheet using VBA:
Files attached:
From some research (as I don't really know what I am doing), I've established I need to create a command button on 1 sheet. Then assign a macro to it which will be the VBA script.
So something like the below:
Thank you in advance for any help as I really do appreciate it
I would like to find a way of automating "getting" certain data from a log.txt file as doing this manually via notepad++ is extremely tedious - let alone time consuming.
Any help would be highly appreciated in getting this automated at the click of a button within Excel, assuming it is feasible?
Please note that even though I have had some programming experience in the past (2003) I am not so confident in myself so please treat me as such. I also suffer mental health and my concentration is poor at the moment. i.e. Please be kind. Thank you.
The data I would like to find within a text file to transfer into an Excel worksheet using VBA:
Files attached:
- output_log.txt = Contains the data
- results.xlsm = Data retrieved manually by using the "search" feature in notepad++ (i.e. the end result I would like to have)
- vba_help.jpg (g drive link) = Please refer to this when reading the description below as it will aid your understanding considerably
- Flight No = an aircraft's flight number
- Type = if it is a departure aircraft or an arrival aircraft
- Time = the time this aircraft landed (or took off) successfully
- Runway = the runway that the aircraft landed or took off from
- Entry Point = the taxiway that an aircraft used to enter the runway (dep. only)
- The flight no (consider this to be the unique identifier) can be found on every single line of code mentioned below
- To find out "Type" and "Time" we can look for these specific statements:
a) Dep. aircraft = e.g. line 9510 " from STATE_TAKEOFFUP to STATE_FLYAWAY"
-- i.e. the log file is telling us that this aircraft (NKS906) took off successfully at 11:55:25
b) Arr. aircraft = e.g. line 9572 " to STATE_ESCAPE_RUNWAY"
-- i.e. the log file is telling us that this aircraft (FFT1577) landed successfully at 11:56:37
- I've covered Time in step 2 above
- The runway can be obtained from the same line as the successful landing/takeoff line. Or we can obtain this from the last instance of the "Entry Point" in the log file (see below).
- The entry point is only applicable to departure aircraft. There can be more than one instance of this. However; that said, it is always the last instance of this string in the log file which is the correct data that is required.
e.g. line 9530 "Route is: GA_term_1, H, F, D, calculate time: 0.002258301s highest count: 1278"
It is the last letter that is required (just before "calculate time") - highlighted as blue text above.
An example in this log file of one departure having more than one instance of this "entry point" would be SWA3029:
line 9391, it's route is "Route is: Term_C7, B4, C, B, calculate time: ...."
... whereas later, on line 9426...
line 9426 it's route changes to "Route is: B4, B, A2, calculate time: ..."
From some research (as I don't really know what I am doing), I've established I need to create a command button on 1 sheet. Then assign a macro to it which will be the VBA script.
So something like the below:
Code:
Private Sub getresultsButton_Click()
Dim ... variables As Integer / String (where required)
Some kind of loop???
If statements???
End If statements
End Loop
End Sub