first commit
This commit is contained in:
1 parent
ae53e9eac5
commit
91cbd01126
514 files changed
+55625
-2203
No files matched your search
Executable
+46
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
from openpyxl import load_workbook
|
||||
from tqdm import tqdm
|
||||
# Define the base paths for the dataset
|
||||
base_path = "/data5/Temp_ProjectData/QiJianProject/2022ZD0116304-202405/Videos/VOD"
|
||||
workbook_path = "/data1/Hatcher/model/project/MPKFNet/大规模数据库-视频.xlsx" # Update this with the actual path to the Excel file
|
||||
|
||||
# Load the Excel workbook and select the active sheet
|
||||
workbook = load_workbook(workbook_path)
|
||||
sheet = workbook.active # Assuming the active sheet is the one we need
|
||||
|
||||
# Function to update the Excel with new video data
|
||||
def update_excel_with_video_data(base_path, sheet):
|
||||
# Find the last row with data to continue from there
|
||||
last_row = sheet.max_row + 1
|
||||
a = 0
|
||||
# Iterate through all subfolders in the base directory
|
||||
for folder_name in tqdm(os.listdir(base_path)):
|
||||
video_folder_path = os.path.join(base_path, folder_name, "videos")
|
||||
label_folder_path = os.path.join(base_path, folder_name, "videos_csv")
|
||||
# a = a+1
|
||||
# if a>2:
|
||||
# break
|
||||
if os.path.isdir(video_folder_path) and os.path.isdir(label_folder_path):
|
||||
video_files = os.listdir(video_folder_path)
|
||||
|
||||
# Iterate through all video files in the video folder
|
||||
for video_name in video_files:
|
||||
video_path = os.path.join(video_folder_path, video_name)
|
||||
label_path = os.path.join(label_folder_path, os.path.splitext(video_name)[0] + '.csv')
|
||||
|
||||
if os.path.isfile(video_path) and os.path.isfile(label_path):
|
||||
# Fill the Excel sheet
|
||||
sheet.cell(row=last_row, column=1, value=last_row) # Sequence number
|
||||
sheet.cell(row=last_row, column=2, value=video_path) # Video data
|
||||
sheet.cell(row=last_row, column=3, value=label_path) # Label (CSV path)
|
||||
sheet.cell(row=last_row, column=4, value=1) # Data function type is always 1
|
||||
|
||||
# Increment the row index for the next entry
|
||||
last_row += 1
|
||||
|
||||
# Save the updated workbook
|
||||
workbook.save(workbook_path) # Save the changes to the same file
|
||||
|
||||
# Uncomment the following line to run the function with actual file paths in a real environment
|
||||
update_excel_with_video_data(base_path, sheet)
|
||||
Reference in new issue
Block a user