postgersql 处理CSV文件

原创
2022/10/30 21:54
阅读数 35

处理原始文件

yum install dos2unix.x86_64
dos2unix BPM2310.xml
cat BPM2310.xml.taskid_row.txt |awk -F" " '{print $13,$15}' > BPM2310.xml.taskid_tab.txt
 
数据示例
more BPM2310.xml.taskid_tab.txt
ModelMachineApply 1001452
ModelMachineContact 1001452
Purchase_Requirements_Budget_Approval 1394346
Purchase_Requirements_Budget_Person 1394346
Purchase_Requirements_Budget_Assets 1394346
Purchase_Requirements_Budget_Details 1394346
Purchase_Requirements_DevExpert 1394346
Purchase_Requirements_NormItem 1394346
Purchase_Requirements_OtherExpert 1394346
Purchase_Requirements_ProduceExpert 1394346
ModelMachineApply 1001452
CSV建表
create EXTENSION file_fdw; 
CREATE SERVER file_fdw_server FOREIGN DATA WRAPPER file_fdw; 
drop foreign table bpmtasktab; 
CREATE FOREIGN TABLE bpmTaskTab ( tab varchar(100), task_id varchar(100) ) 
SERVER file_fdw_server OPTIONS (format 'csv', header 'false', filename '/opt/temp/BPM2310.xml.taskid_tab.txt', delimiter ' ', null''); 

select * from bpmTaskTab limit 10;

 

 
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部