Home > other >  [with] to a directory of all fixed two TXT file within the folder for some replace operation, then g
[with] to a directory of all fixed two TXT file within the folder for some replace operation, then g

Time:09-22

Want to/A/B/C/D/E/all directory folder and subfolders within the fixed two TXT file for some replace operation, and then generate A new file,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
The import glob
The import re

With the open (glob. Glob (OS) path) join ('/A/B/C/D/E/*/*/*/, X.t xt ')), 'r') as filereader1:
With the open (glob. Glob (OS) path) join ('/A/B/C/D/E/*/*/*/, X_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)

With the open (glob. Glob (OS) path) join ('/A/B/C/D/E/*/*/*/, Y.t xt ')), 'r') as filereader2:
With the open (glob. Glob (OS) path) join ('/A/B/C/D/E/*/*/*/, Y.t xt ')), 'w') as filewriter2:
For the row in filereader2:
If "Rank" in a row:
The row=row. Replace (' Rank ', ')
Filewriter2. Write (row)
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
At this wrong:
TypeError: expected STR, bytes or OS. PathLike object, not a list

CodePudding user response:

 glob. Glob (OS) path) join ('/A/B/C/D/E/*/*/*/, X.t xt ') 
the got the file list, not A single file

CodePudding user response:

Good thank god
  • Related