Jul-09-2022, 01:39 PM
(This post was last modified: Jul-09-2022, 08:25 PM by Yoriz.
Edit Reason: Added code tags
)
Hi,
I am a beginner of python trying to learn through jupyter notebook.
I have a text file that contains close to 100k lines.
One sample line is as below. I need to create 3 columns with the names cellId, rbStart, ipn.
Values of these names are part of each line. Sometimes, all lines may not carry the required data and may have different data in those lines.
Thanks in advance.
I am a beginner of python trying to learn through jupyter notebook.
I have a text file that contains close to 100k lines.
One sample line is as below. I need to create 3 columns with the names cellId, rbStart, ipn.
Values of these names are part of each line. Sometimes, all lines may not carry the required data and may have different data in those lines.
Output:Line 125: [2021-08-22 22:09:32.868188] 0x84e51a08=(bfn:2126, sfn:78, sf:5.40, bf:160) duId:1 EMCA4/BbiUniqueTrace 2 UPCUEULNR.207 upcueulnrce_ueactor_estimateulgain.c:242: <!UPCUEULNR.207!> TRACE3 cellId=2, bbUeRef=0x00009ea0 puschSfn=78 puschSlot=9 : Estimated UL gain from PUSCH power report. postEqSinr=61.0 rbStart=150 rbLength=10 ipn=-109.05000305175781 pcMaxC=25.5 backoffPsd=0.0 pcMaxInUse=25.5 ulPsdTxPhr=42.21849060058594 slotCounter=116236385
I have tried using the below code in Jupyter notebook. But it is resulting in only 1 line and not all the lines. That too it gives result like this:Output:['cellId', 'rbStart', 'rssi']
cellId=2 rbStart=150 ipn=-109.05000305175781
df = pd.read_table("C:\\Users\\newFile.txt") for line in df: cellId = re.findall("cellId.\d+",line) rbStart = re.findall("rbStart.\d+",line) rssi = re.findall("ipn.[-]\d{3}.\d+",line) Headers = ['cellId', 'rbStart', 'rssi'] print(Headers) print (cellId[0],rbStart[0],rssi[0])Expectation is to print as below
Output:cellId rbStart rssi
2 150 -109.05000305175781
Can you please help me with the corrections in my code.Thanks in advance.