Skip to content

write_scene_list(csv_file) #523

Closed

Description

@frelevesque

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

Activity

  1. frelevesque commented on Oct 18, 2025

    @frelevesque
    Author

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

  2. Breakthrough commented on Jul 5, 2026

    @Breakthrough
    Owner

    I'll add a clarifying comment in v0.7.1 including the rationale behind this, but in your edited comment you got it. Files need to be used with a context manager to make sure they get closed correctly, so the correct invocation is:

    with open("scenes.csv", "w") as f:
        write_scene_list(f, scenes)
  3. Breakthrough commented on Aug 17, 2026

    @Breakthrough
    Owner

    You are correct that this should probably accept both - numpy, imageio, and pandas all allow this.

    Where they differ is on the arg name itself, so we can leave that as-is. I'm a fan of numpy's definition as file: file, str, or pathlib.Path.

  4. added a commit that references this issue on Aug 19, 2026
    3f5b5f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions