Saya akhirnya menggunakan perintah copy_expert. Perhatikan bahwa pada Windows, Anda harus mengatur izin file. Postingan ini sangat berguna menyetel izin .
with open(the_file, 'r') as f:
sql_copy_statement = "copy {table} FROM '"'{from_file}'"' DELIMITER '"'{deli}'"' {file_type} HEADER;".format(table = the_table,
from_file = the_file,
deli = the_delimiter,
file_type = the_file_type
)
print sql_copy_statement
cur.copy_expert(sql_copy_statement, f)
conn.commit()