https://github.com/postgrest/pg_csv
CSV aggregate for Postgres
https://github.com/postgrest/pg_csv
csv postgres postgresql postgresql-extension
Last synced: 5 months ago
JSON representation
CSV aggregate for Postgres
- Host: GitHub
- URL: https://github.com/postgrest/pg_csv
- Owner: PostgREST
- License: mit
- Created: 2025-08-02T01:52:09.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-08-02T02:07:46.000Z (5 months ago)
- Last Synced: 2025-08-02T04:42:54.820Z (5 months ago)
- Topics: csv, postgres, postgresql, postgresql-extension
- Language: C
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pg_csv

[](https://coveralls.io/github/PostgREST/pg_csv)
[](https://github.com/PostgREST/pg_csv/actions)
## Installation
Clone this repo and run:
```bash
make && make install
```
To install the extension:
```psql
create extension pg_csv;
```
## csv_agg
Aggregate that builds a CSV as per [RFC 4180](https://www.ietf.org/rfc/rfc4180.txt), quoting as required.
```psql
select csv_agg(x) from projects x;
csv_agg
-------------------
id,name,client_id+
1,Windows 7,1 +
2,Windows 10,1 +
3,IOS,2 +
4,OSX,2 +
5,Orphan,
(1 row)
```
It also supports adding a custom delimiter.
```psql
select csv_agg(x, '|') from projects x;
csv_agg
-------------------
id|name|client_id+
1|Windows 7|1 +
2|Windows 10|1 +
3|IOS|2 +
4|OSX|2 +
5|Orphan|
(1 row)
```
> [!IMPORTANT]
> Newline, carriage return and double quotes are not supported as delimiters to maintain the integrity of the separated values format.