How can this Python-code become translatable to JS

Unfortunately, my online experiment does not run as I get the error message "

  • ReferenceError: get_file_name is not defined

In Psychopy it seems that the Python code is not translatable to JavaScript. Does anyone have a hint what is wrong here?

def get_file_name(code_text, csv_file_path):
    with open(csv_file_path, 'r') as file:
        lines = file.readlines()
        header = lines[0].strip().split(',')
        vp_code_index = get_column_index(header, "part_code")
        file_index = get_column_index(header, "file")

        for line in lines[1:]:
            row = line.strip().split(',')
            if row[code_index] == code_text:
                return row[file_index]
    return None

I don’t think JS understands “with x as y”. Also, I don’t think your code will work online.

Have a look at my Moving Cue and Trial Switching online demos for how to load a spreadsheet in a code component online.