PySceneDetect icon indicating copy to clipboard operation
PySceneDetect copied to clipboard

write_scene_list(csv_file)

Open frelevesque opened this issue 2 months ago • 1 comments

Description:

Hello,

Thank you for that amazing package.

When using the line :

write_scene_list(
        "csvfile.csv",
        scene_list, 
        include_cut_list=True, 
        cut_list=None, 
        col_separator=',', 
        row_separator='\n'
        )

I get the error : csv_writer = csv.writer(output_csv_file, delimiter=col_separator, lineterminator=row_separator)
TypeError: argument 1 must have a "write" method

Problem

write_scene_list passes a string to csv.writer and not a writable open file.

My fix for now is :

write_scene_list(
        open("csvfile.csv", "w", newline=""),
        scene_list, 
        include_cut_list=True, 
        cut_list=None, 
        col_separator=',', 
        row_separator='\n'
        )

edit1: readability edit2: i should do something like :

with open("csvfile.csv", "w", newline="") as f:
        write_scene_list(
                f,
                scene_list, 
                include_cut_list=True, 
                cut_list=None, 
                col_separator=',', 
                row_separator='\n'
                )

Environment:

[PySceneDetect] PySceneDetect 0.6.7.1

System Info

OS Windows-10-10.0.19045-SP0 Python CPython 3.12.9 Architecture 64bit + WindowsPE

Packages

av Not Installed click 8.1.8 cv2 4.11.0 imageio Not Installed imageio_ffmpeg Not Installed moviepy Not Installed numpy 1.26.4 platformdirs 4.3.7 scenedetect 0.6.7.1 tqdm 4.67.1

Tools

ffmpeg 8.0-full_build-www.gyan.dev mkvmerge v95.0 ('Goodbye Stranger') 64-bit

frelevesque avatar Oct 18 '25 03:10 frelevesque

My point is I think it should do it inside the write_scene_list function.

frelevesque avatar Oct 18 '25 04:10 frelevesque