I have some data in my notepad which looks like this :
node1
7
p 2
r 5
node2
6
p 2
r 4
I want to convert these data to excel file using python so that a excel is created with rows as node1 and node2 and columns will be : total , primary and replicas ie p means primary , r means replicas and digit goes to column called "total . So basically in excel it should like below :

The easiest way to transfer data to Excel is using CSV file.
The main idea is to read four lines sequentially then make one row from them and write the row into the CSV file "data.csv".
Your data will be look like this
Next you should open "data.csv" in Excel.
Some explanations:
It's possible to write the data into XLSX file but it's a few harder.