I did this code. This code elemenate all spaces and replace it with (_), but it
ID: 3893524 • Letter: I
Question
I did this code. This code elemenate all spaces and replace it with (_), but it is only able to do it for only one file. I want help in making loop, so it can do it for all files automatically with out going from one file to the other. ASM95948vt Oreplace.py (-/Desktop/tree/noplasmid)-gedit OpenA protein11.faa ? GCA 000961S15.1 CCA 00096355S.1 GCA 000971565.1 GCA 001010765.1 GCA 001028665. 1 ASM9715ov1 ASM96355w1 protein faa ASM1010761 proteinfaa ASM102866v1 protein faa1file 1 open( GCA 000007125.1 ASH712v1 protein.faay 2 content file 1.read) file 1.close() 4 Q content.replace CCA 0012443151 CCA 001262015.1 CCA 0012779751 GCA 001277895.1 GCA 001277975.ron ASM124431v1 ASM126201v1 ASM127787v1 ASM127797Vvfie 2open CCA 000007125.1 ASA712v1proteln.fa protein982.faa 7witeco) ASM127789v1 a file 2.ctose GCA 0013055951 GCA 001318181 GCA 0013182451 GCA.0014114951 GCA 001411805.1 ASM131824v1 ASM1305591 protein faa ASM131818v1 ASM1411491 1651.faa protein faa ASM1411 protein.faaprotein8p1 protein.faa GCA, 001447075.1 GCA 001449005.1 GCA 001455325.1 GCA.001456065.2 GCA 001465175.1 ASM144707vsASM144900v1 protein faa ASM145532vASM145606v2 ASM146517v1 protein faaproteinkNU Lon .fea proteinukY6D1.aa ASM155843v2 A ASM155847v2 ASM1558492 ASM15585tv2 protein faa proteiATCC 178. proteinATL 6130 protein faa CCA 0016856251 CCA 0017154251 CCA 001718515 GCA 0017188951 CCA 001729545.1 ASM171542V1 ASM171889ASM172954v1 CCA-001687495 1· CCA 001BS7515.1., ASM188751v1 CCA,001887615.s_ ASM1S8761v1 cca_001887635 1- ca001 7655.1 188763w1 ASM188765v1 replace pyExplanation / Answer
The code currently doing the processing for one file we can call the functonality
for all the files as follows:
import os, sys
inp = input("Enter the path:")
list = os.listdir( path )
'''
In case all the filenames end with .faa we can use this information
'''
for file in list:
if file.endswith("faa"):
Your code
Pls remember in yoor code to relace the file name with "file".e.g
in place of GCA_0000000... we should have "file" as used in the above
code
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.