0

I have 16 bz2 files of bz2 format: split.csv.0.bz2 split.csv.1.bz2 split.csv.2.bz2 ....

I believe this is a compressed csv file, but what makes me confused all day today is that it's splitted by 16 diff files.

I tried to decompress them all at once, but it's returning split.csv.0 split.csv.1 split.csv.2 .... 16 different files those are saying its file format is digit (format: 0, 1, 2....)

How should I work with these bz2 files to make it as a original csv file? I'm using Mac.

Tetsujin
  • 50,917

1 Answers1

1

These digits are not "formats" nor "extensions"; each is just a part of the respective filename. The content matters.

If the compressed files decompress without errors then I suspect all you need is to concatenate the resulting files in the right order. The natural order is probably the right one. Here I assume the last file is split.csv.15. Adjust the approach if needed.

In a shell that expands {0..15} (e.g. in Bash) the following command should work (warning: it will overwrite result.csv):

cat split.csv.{0..15} > result.csv

In any sane shell you can specify all the names explicitly:

cat split.csv.0 split.csv.1 split.csv.2 … > result.csv

(In case it's not obvious: replace with the rest of the filenames.)

Note cat split.csv.* is probably not a good idea. Even if there are no extra files matching the pattern (e.g. the .bz2 files), the shell will probably expand split.csv.* to filenames in the wrong order. Compare the output of echo split.csv.*.