Feb 18 2024 05:55 PM - edited Feb 18 2024 05:59 PM
Re:
https://techcommunity.microsoft.com/t5/excel/power-query-help/m-p/4059319#M220947
I can not open original thread with my smart phone so I open a new thread here
http://e.anyoupin.cn/Edata/?p=tools.ceshi.index/downloadTreeFile&file=/excel/fileOut.csv.zip
As I can not upload the result .zip file here(see attached image.),I share a link above.
Yes I just pull all.data without headers.
And there is no column about 1980 Jan 12 04:29:31.127 [BB] 0xB132 LTE LL1 PDSCH Decoding Results in your expected result.
Feb 18 2024 07:40 PM - edited Feb 18 2024 10:30 PM
add time stamp
<?php
function parseBody(){
$files=glob('*.txt');
$handleOut=fopen('fileOut.csv','w');
$pattern='/Frame|RNTI Type|Excess Time|TB Ext 0|On Dur/';
foreach($files as $filename){
$handle = fopen ($filename, "r");
$new_line="";
$prefix="";
while (!feof ($handle))
{
$buffer = fgets($handle, 4096);
$line = trim($buffer);
//here add time stamp
if(preg_match('/1980 Jan/',$line,$m)){
if($prefix==""){
$prefix=$line;
$prefix_next=$line;
}else{
$prefix=$prefix_next;
$prefix_next=$line;
}
}
if(preg_match('/TB Info Record\[.*\]/',$line,$m)){
if($new_line<>""){
$new_line=str_replace(',,',',',$new_line);
$new_line=trim($new_line,',');
$new_line=$prefix.','.$new_line;
fwrite($handleOut,$new_line."\n");
$new_line=$m[0];
}else{
$new_line=$m[0];
}
}
if(preg_match($pattern,$line)){
$buffer = fgets($handle, 4096);
$buffer = fgets($handle, 4096);
$line = trim($buffer);
$new_line.=str_replace('|',",",$line);
}
}
$prefix=$prefix_next;
$new_line=str_replace(',,',',',$new_line);
$new_line=trim($new_line,',');
$new_line=$prefix.','.$new_line;
fwrite($handleOut,$new_line);
fclose ($handle);
}
fclose($handleOut);
}
parseBody();
Mar 01 2024 03:46 PM