如何解决PgAdmin 将文本列导出到 csv 文件
我有一个包含 3 列的表格 - 类型、名称和代码。
code
列包含过程/函数源代码。
我已使用 Import/Export
中的 PgAdmin 4 v5
选项将其导出到 csv 文件,但 code
列不坚持 csv 文件中的单个单元格。其中的数据分布在许多行和列中。
我已检查 Encoding
为 UTF8
,它在导出其他表时正常工作。
其他设置:Format: csv
、Encoding: UTF8
。没有更改任何其他设置
有人可以帮助如何正确导出它。
解决方法
对所见内容的解释:
CREATE TABLE public.csv_test (
fld_1 character varying,fld_2 character varying,fld_3 character varying,fld_4 character varying
);
insert into csv_test values ('1',E'line with line end. \n New line','test','dog');
insert into csv_test values ('2','dog');
insert into csv_test values ('3',E'line with line end. \n New line \n Another line','test2','cat');
insert into csv_test values ('4',E'line with line end. \n New line \n \t Another line','test3','cat');
select * from csv_test ;
fld_1 | fld_2 | fld_3 | fld_4
-------+-----------------------+-------+-------
1 | line with line end. +| test | dog
| New line | |
2 | line with line end. +| test | dog
| New line | |
3 | line with line end. +| test2 | cat
| New line +| |
| Another line | |
4 | line with line end. +| test3 | cat
| New line +| |
| Another line | |
\copy csv_test to csv_test.csv with (format 'csv');
\copy csv_test to csv_test.txt;
--fld_2 has line ends and/or tabs so in CSV the data will wrap inside the quotes.
cat csv_test.csv
1,"line with line end.
New line",test,dog
2,dog
3,"line with line end.
New line
Another line",test2,cat
4,"line with line end.
New line
Another line",test3,cat
-- In text format the line ends and tabs are shown and not wrapped.
cat csv_test.txt
1 line with line end. \n New line test dog
2 line with line end. \n New line test dog
3 line with line end. \n New line \n Another line test2 cat
4 line with line end. \n New line \n \t Another line test3 cat
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。