To compress a file through an export procedure, you can pass in config parameter the value compression: COMPRESSION_TYPE, where COMPRESSION_TYPE can be BYTES, GZIP, BZIP2, DEFLATE, BLOCK_LZ4 or FRAMED_SNAPPY. By default is NONE, that is without compression.

Note that to compress a file, you have to specify both the base file extension and the compression extension, for example to export a test.csv you can write test.csv.gz, or test.csv.bz2 or whatever. For example:

CALL apoc.export.csv.all("test.csv.gz", {compression: "GZIP"})

This works also with a multi-file export, for example:

CALL apoc.export.csv.all("testBulk.csv.zz",{compression: "DEFLATE", bulkImport: true, separateHeader: true, delim: ';'})

with a series of testBulk.<nodes/relationships>.<label/rel>.csv.zz files.

Moreover, you can use it with a file split into batches:

CALL apoc.export.csv.all(null, {compression: 'DEFLATE',stream:true,batchSize:2,useOptimizations:{unwindBatchSize:2}})
YIELD data RETURN data
Table 1. Results
data

compressed byte array

compressed byte array

compressed byte array