This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import re | |
| import sys | |
| # --- 外部関数のインポート --- | |
| # 実際のプロジェクト構成に合わせてパスを調整してください | |
| # 例: sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'libs'))) | |
| try: | |
| from youtube_search import search_youtube_videos | |
| from youtube_transcript import get_transcript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import json | |
| import os | |
| # 設定ファイルからAPIキーを読み込む関数 | |
| def load_api_key(config_path="config.json"): | |
| """ | |
| 設定ファイル(JSON形式)からAPIキーを読み込む。 | |
| Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 必要なモジュールをインポートします | |
| import sys # 標準エラー出力 (stderr) を使用するためにインポートします | |
| from youtube_transcript_api import YouTubeTranscriptApi, NoTranscriptFound, TranscriptsDisabled # YouTube Transcript APIライブラリから必要なクラスと例外をインポートします | |
| def get_transcript(video_id): | |
| """ | |
| 指定されたYouTube動画IDの文字起こしを取得する関数。 | |
| 日本語または英語の文字起こしを優先的に取得します。 | |
| Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import json | |
| import os | |
| # 設定ファイルからAPIキーを読み込む関数 | |
| def load_api_key(config_path="config.json"): | |
| """ | |
| 設定ファイル(JSON形式)からYouTube APIキーを読み込みます。 | |
| Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 必要なライブラリをインポートします | |
| import pandas as pd # データを扱うための必須ライブラリ。Excelファイルの読み込み、データ結合、集計に使います。 | |
| import os # ファイルやディレクトリ(フォルダ)に関する操作を行うための標準ライブラリ。今回は主にファイル名の扱いに使います。 | |
| import glob # 指定したパターンに一致するファイル名を探すための標準ライブラリ。 | |
| # --- 設定 --- | |
| # 集計したいExcelファイルを自動で見つけるためのパターンを指定します。 | |
| # このPythonスクリプトと同じフォルダにあるファイルのうち、 | |
| # ファイル名が「どんな文字でもいい(*)」の後に「_売上.xlsx」という形になっているものを探します。 | |
| # 例: '東京支店_売上.xlsx', '大阪支店_売上.xlsx' など |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import os | |
| import numpy as np # 乱数生成のためにnumpyをインポート | |
| # サンプルファイルを作成するフォルダ名 | |
| # このスクリプトと同じ場所にファイルが保存されます。 | |
| output_dir = '.' # 現在のディレクトリを指定 | |
| # 作成する支店リストとファイル名パターン | |
| branches = ['東京支店', '大阪支店', '福岡支店', '名古屋支店', '札幌支店'] |