Convert notepad to excel

Hi All,

I have some data in my notepad like this :
node1
7
p 2
r 5
node2
6
p 2
r 4

Now i want to convert text data of this notepad file as stated above to “Excel” like below :

I mean i want my python code to understand that p means primary and r means replicas

you can try this code
"import openpyxl

wb = openpyxl.Workbook()
ws = wb.active

headers= [“nodename”.“total”,“primary”,“replicaas”]
ws.append(headers)

data_entries = [[“node10”,“7”,“2”,“5”],[“node02”,“6”,“2”,“4”]]

for entry in data_enteries : ws.append(entry)

wb.save(“node.xlsx”)
"