Ramin Zahedi
Ramin Zahedi

Reputation: 485

What delimiter should be used for string_to_array command at PostgreSQL for a tab separated text?

I'm querying a one-column table, the output of the query is of type text. I want to check the cardinality of the results. I'm using the string_to_array command, but I don't know what I should put for the delimiter. The following two commands don't work:

select rec from papers_stg where cardinality(string_to_array(rec,'    ')) <> 11
select rec from papers_stg where cardinality(string_to_array(rec,'\t')) <> 11

Here are the first two rows of table papers_stg:

7B5EDC52        Antibacterial Activity and Post-Antibiotic Effect of Flurithromycin Compared with Other Macrolides and Penicillins Against Periodontal Pathogens        antibacterial activity and post antibiotic effect of flurithromycin compared with other macrolides and penicillins against periodontal pathogens        2013    2013/07/18      10.1179/joc.2001.13.3.255       Journal of Chemotherapy journal of chemotherapy 0794F580                19555
7932AE5F        In Vitro Activity of Cefdinir against Respiratory Pathogens Isolated in Sicily with Reference to Beta-Lactamase Production      in vitro activity of cefdinir against respiratory pathogens isolated in sicily with reference to beta lactamase production      2013    2013/07/18              Journal of Chemotherapy journal of chemotherapy 0794F580                19555

And here is the table description:

 Table "public.papers_stg"
 Column | Type | Modifiers 
--------+------+-----------
 rec    | text | 

Upvotes: 1

Views: 357

Answers (1)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125414

String Constants with C-style Escapes

string_to_array(rec, E'\t')

Upvotes: 1

Related Questions