如何在bash编程循环中制作每个文件夹中的txt文件?文件中必须有文字。
这里是使用while执行文件夹的语法:
import openpyxl, os
from selenium import webdriver
os.chdir('C://Users/user/Documents')
os.makedirs('GenBank Data', exist_ok = True)
book = openpyxl.load_workbook('Squirrel list 50 percent genus.xlsx')
sheet = book.active
dirs = 'C://Users/user/Documents/GenBank Data'
os.chdir(dirs)
browser = webdriver.Chrome(executable_path = 'C://Users/user/chromedriver.exe',
service_args = ['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])
start_col = 7
end_col = 9
start_row = 2
end_row = 160
url_root = 'https://www.ncbi.nlm.nih.gov/nuccore/'
url_end = '.1?report=fasta'
for y in range(start_col, end_col + 1):
file = open(sheet.cell(row = 1, column = y).value, 'w')
for x in range(start_row, end_row + 1):
accession = sheet.cell(row = x, column = y).value
if accession:
print(accession)
url = url_root + accession + url_end
browser.get(url)
data = browser.find_element_by_tag_name('pre')
file.write(data.text + '\n' + '\n')
browser.quit()
file.close()
答案 0 :(得分:0)
#!/bin/bash COUNTER=1 while [ $COUNTER -le 10 ]; do mkdir folder_$COUNTER; cat text_file.txt > folder_$COUNTER/file_${COUNTER}.txt; let COUNTER=$COUNTER+1 done