Added quick review of csv
This commit is contained in:
41
quickprocessreport.py
Normal file
41
quickprocessreport.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import csv
|
||||
|
||||
def process_row(row):
|
||||
# Skip if accepted column already has a value
|
||||
if row['accepted'].strip():
|
||||
return
|
||||
|
||||
# Skip if required fields are missing
|
||||
try:
|
||||
size_ratio = float(row['size_ratio'])
|
||||
ssim_score = float(row['ssim_score'])
|
||||
except (ValueError, TypeError):
|
||||
return
|
||||
|
||||
# Check if audio and subtitles match
|
||||
if row['audio_match'] != 'O' or row['subs_match'] != 'O':
|
||||
row['accepted'] = 'x'
|
||||
return
|
||||
|
||||
# Apply acceptance rules
|
||||
if size_ratio < 0.7 and ssim_score > 0.99:
|
||||
row['accepted'] = 'o'
|
||||
elif size_ratio < 0.7 and ssim_score > 0.95:
|
||||
row['accepted'] = 'r'
|
||||
else:
|
||||
row['accepted'] = 'x'
|
||||
|
||||
# Read and process the CSV
|
||||
with open('av1_quality_report.csv', 'r') as f:
|
||||
reader = csv.DictReader(f)
|
||||
rows = list(reader)
|
||||
|
||||
# Process each row
|
||||
for row in rows:
|
||||
process_row(row)
|
||||
|
||||
# Write updated data back to CSV
|
||||
with open('av1_quality_report.csv', 'w', newline='') as f:
|
||||
writer = csv.DictWriter(f, fieldnames=reader.fieldnames)
|
||||
writer.writeheader()
|
||||
writer.writerows(rows)
|
||||
Reference in New Issue
Block a user