~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Def the Replace () : # 1 (functions) : a custom function to Replace QCAT. TXT file content function. For QCAT. TXT in QAM, retransmission MCS and Rank to Replace
Print (' \ n ~ ~ ~ ~ ~ @ @ @ @ @ # # # # # $$$$$% % % % % & amp; & & & & * * * * * Attention! Now Start To Replace QCAT. TXT * * * * * & amp; & & & & % % % % % $$$$$# # # # # @ @ @ @ @ ~ ~ ~ ~ ~ \ n ')
QamMcs=input (" Dear, do difference me the filename that contains' QAM and MCS '... \ n \ n ") # # user custom to deal with the inclusion of QAM and retransmission of MCS information file name, contains. TXT
Rank=input (" \ nDear, both please difference me the filename that contains' Rank '... \ n \ n ") # # inclusion Rank information of user custom to deal with the filename, contains. TXT
P=Path (Path)
For file in p.r glob (' *.txt) :
F=STR (file)
If QamMcs in f:
# if 'QAM_MCS_8150. TXT in f: # Hardcode definition file name
With the open (f, 'r') as filereader1:
With the open (f.r eplace (. TXT ', '_new. TXT'), 'w') as filewriter1:
For the row in filereader1:
If "256 qam" in a row:
The row=row. Replace (' 256 qam ', '8')
Elif "64 qam" in a row:
The row=row. Replace (' 64 qam ', '6')
Elif "16 qam" in a row:
The row=row. Replace (' 16 qam ', '4')
Elif "QPSK" in a row:
The row=row. The replace (' QPSK ', '2')
Elif, "31," in a row:
Row=row. Replace (', 31, 'and', ')
Elif ", 30, "in a row:
Row=row. Replace (', 30, 'and', ')
Elif ", 29, "in a row:
Row=row. Replace (', 29, 'and', ')
Elif ", 28, "in a row:
Row=row. Replace (', 28, 'and', ')
Filewriter1. Write (row)
Print (' \ n ~ ~ ~ ~ ~ @ @ @ @ @ # # # # # $$$$$% % % % % & amp; & & & & * * * * * Congratulations! QAM and Retransmission MCS have had replaced the done! * * * * * & amp; & & & & % % % % % $$$$$# # # # # @ @ @ @ @ ~ ~ ~ ~ ~ \ n \ n ')
OS. Remove (f)
Print (' ~ ~ ~ ~ ~ @ @ @ @ @ # # # # # $$$$$% % % % % & amp; & & & & * * * * * Congratulations! From the does old '+ QamMcs +'! * * * * * & amp; & & & & % % % % % $$$$$# # # # # @ @ @ @ @ ~ ~ ~ ~ ~ \ n \ n ')
Elif QamMcs not in f:
Print (' ~ ~ ~ ~ ~ @ @ @ @ @ # # # # # $$$$$% % % % % & amp; & & & & * * * * * Sorry but '+ QamMcs +' is not correct filename, both please double - check and re - input later. Now let us restart! * * * * * & amp; & & & & % % % % % $$$$$# # # # # @ @ @ @ @ ~ ~ ~ ~ ~ \ n ')
The Replace ()
CodePudding user response:
Is a multiple replacement? Can be used if it for you