如何将多列制表符分隔的文本文件导入到单个列PostgreSQL表中?

时间:2016-12-29 10:11:04

标签: sql postgresql text

我有一个30 GB的制表符分隔文本文件,有11列。我想将它导入单列PostgreSQL表。我怎么能这样做?

我应该在\ copy命令中为delimiter变量添加什么?每个字符都可能存在于文本文件中。如何强制PostgreSQL将文件视为一个列文件?

下面是数据的前5行,有些行不是英文,可以是任何语言。

01B27BE8    Evaluating Polarity for Verbal Phraseological Units evaluating polarity for verbal phraseological units 2014    2014/11/16  10.1007/978-3-319-13647-9_19    mexican international conference on artificial intelligence micai       42D7146F    19517
027D0030    Automatic Monitoring the Content of Audio Broadcasted by Internet Radio Stations    automatic monitoring the content of audio broadcasted by internet radio stations    2012    2012/10/27  10.1007/978-3-642-37807-2_11    mexican international conference on artificial intelligence micai   42D7146F    19444
7CFE299E    Towards a set of Measures for Evaluating Software Agent Autonomytowards a set of measures for evaluating software agent autonomy    2009    2009/11 10.1109/MICAI.2009.15   mexican international conference on artificial intelligence micai       42D7146F    18870
59BEBE1C    Learning Probability Densities of Optimization Problems with Constraints and Uncertainty    learning probability densities of optimization problems with constraints and uncertainty    2008    2008/10/27  10.1007/978-3-540-88636-5_25    mexican international conference on artificial intelligence micai       42D7146F    19444
5873C011    Towards a Model for an Immune System    towards a model for an immune system    2002    2002/04/22  10.1007/3-540-46016-0_42    mexican international conference on artificial intelligence micai       42D7146F19177

1 个答案:

答案 0 :(得分:1)

使用例如\x01作为分隔符适用于我:

\copy the_table from 'data.txt' with (delimiter E'\x01')