def get_image_list(): images_path = WindowsPath('./images/StarWars/cards') filenames = [] for name in images_path.glob('*.png'): filenames.append(name) return filenames
def load_estimators(path: WindowsPath) -> List[Tuple]: """ Returns a list of estimators for the VotingClassifier """ estimator_list = [] for suffix in ['*.joblib', '*.sav']: for filepath in path.glob(suffix): print(f'Loading {filepath.name}') estimator_list.append((filepath.stem, load(filepath))) return estimator_list
def listup_content_path() -> List[Path]: parent = WindowsPath('D:/aozorabunko/cards') files = list(parent.glob('**/*.html')) # 適当にピック RAND_MAX = 300 DOUBLE_PICK_THR = 10 count = 0 until = randrange(1, RAND_MAX) pickup_files = [] for file in files: if until == count: until = randrange(1, RAND_MAX) if until % DOUBLE_PICK_THR == 0: # たまには2つ連続で取りたい until = 1 pickup_files.append(file) count = 0 count += 1 return pickup_files
def main(): """Command Line Script""" # Prepare to accept command line arguments parser = argparse.ArgumentParser( description="""Combine multiple excel files with a single excel"""\ """ spreadsheet into one excel file with multiple sheets.""" ) parser.add_argument( '-i', '--input_path', help='File path where excel files are located, can be folder or'\ ' individual file' ) parser.add_argument('-o', '--output_file', help='File path to output excel file') parser.add_argument('-g', '--glob', action='store_true', help='Use glob to find files specified by input_path') parser.add_argument('-r', '--recursive', action='store_true', help='Perform glob search recursively') args = parser.parse_args() # handle flags relating to glob usage for file searching # This allows the user to search for files using glob directly if args.glob: files = glob(args.input_path, recursive=args.recursive) data = combine_sheets(files, args.output_file) else: path = WindowsPath(args.input_path) data = combine_sheets([str(p) for p in path.glob('*xls*')], args.output_file) print(f'Successfully created output {args.output_file}')
def merge(p: pathlib.WindowsPath, year: str, item_type: str): """ Обгортка для writer, котра визнає шлях""" files = [p / file_name for file_name in p.glob("*.csv")] name = p.parent / f"{item_type}_{year}.csv" writer(files, name, item_type)
""" ワークスペースに含まれている.classファイルを すべて削除する """ from pathlib import WindowsPath from os import remove target = WindowsPath("D:\java-ii-12") for file in target.glob("**/*.class"): print(file) remove(file)
def getSlimIMGsFromPDFsInFolder(folder): folder = WindowsPath(folder) for pdf in folder.glob('*.pdf'): imglst = extractIMGs(pdf) for img in imglst: silmIMG(img)