How to extract a specific information from a file

1 view (last 30 days)
Hello all,
I have a large file containing data like this
INFO [07-05|15:18:04.004] 🔨 mined potential block number=1078 hash="f6d5bd…58bea5"
INFO [07-05|15:18:04.004] Commit new mining work number=1079 sealhash="e686b6…bceb85" uncles=0 txs=0 gas=0 fees=0 elapsed="508.656µs"
INFO [07-05|15:18:06.004] Successfully sealed new block number=1079 sealhash="e686b6…bceb85" hash="b624ff…c743ae" elapsed=1.999s
INFO [07-05|15:18:06.004] 🔗 block reached canonical chain number=1072 hash="92fe2f…fc6bf1"
INFO [07-05|15:18:06.004] 🔨 mined potential block number=1079 hash="b624ff…c743ae"
INFO [07-05|15:18:06.004] Commit new mining work number=1080 sealhash="c2f151…17e0b6" uncles=0 txs=0 gas=0 fees=0 elapsed="515.946µs"
INFO [07-05|15:18:08.001] Successfully sealed new block number=1080 sealhash="c2f151…17e0b6" hash="f65eab…94b932" elapsed=1.996s
INFO [07-05|15:18:08.001] 🔗 block reached canonical chain number=1073 hash="702dde…1fcf2a"
INFO [07-05|15:18:08.001] 🔨 mined potential block number=1080 hash="f65eab…94b932"
INFO [07-05|15:18:08.002] Commit new mining work number=1081 sealhash="daee7d…2444ae" uncles=0 txs=0 gas=0 fees=0 elapsed="545.658µs"
INFO [07-05|15:18:10.004] Successfully sealed new block number=1081 sealhash="daee7d…2444ae" hash="baf0f0…68ffa6" elapsed=2.002s
INFO [07-05|15:18:26.000] Successfully sealed new block number=1089 sealhash="d645c1…1ed93b" hash="883415…4510e6" elapsed=1.995s
INFO [07-05|15:18:26.000] 🔗 block reached canonical chain number=1082 hash="67aa36…b89cd1"
INFO [07-05|15:18:26.000] 🔨 mined potential block number=1089 hash="883415…4510e6"
I want to extract the information elasped (the one in s and not in µs). I have underlined it
Can somebody help me. Thanks alot

Answers (1)

Apoorv Singh
Apoorv Singh on 9 Jul 2020
copy the whole text to a string. Then search for the keywork "elapsed". Consider the substring from this index till the end of each entry. Once you have this substring, you can further impose the condition that only values in seconds have to be considered.
This seems more like a hack than a nice solution, but I hope this helps :)

Categories

Find more on Foundation and Custom Domains in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!