import csv import os import tempfile def write_temporary_csv(rows): temp_file_descriptor, temp_file_path = tempfile.mkstemp(suffix=".csv") with os.fdopen(temp_file_descriptor, "w", newline="") as temp_file: writer = csv.writer(temp_file) writer.writerows(rows) return temp_file_path