如何将压缩文件导入 Postgres 表 [英] How to import ZIpped file into Postgres Table

查看:83
本文介绍了如何将压缩文件导入 Postgres 表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个重要文件放入我的 Postgresql 系统(特别是 RedShift).我发现了一个允许导入 gzip 文件的副本的争论.但是我试图包含在我的系统中的数据的提供者只生成 .zip 格式的数据.任何用于打开 .zip 的内置 postgres 命令?

I would like to important a file into my Postgresql system(specificly RedShift). I have found a arguement for copy that allows importing a gzip file. But the provider for the data I am trying to include in my system only produces the data in a .zip. Any built in postgres commands for opening a .zip?

推荐答案

来自 Postgres:

From within Postgres:

COPY table_name FROM PROGRAM 'unzip -p input.csv.zip' DELIMITER ',';

来自 unzip -p 的手册页:

-p     extract files to pipe (stdout).  Nothing but the file data is sent to stdout, and the files are always extracted  in  binary
       format, just as they are stored (no conversions).

这篇关于如何将压缩文件导入 Postgres 表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆