I have a single text file that contains a very long string of comma separated number, e.g.:
15,0,-475,-1243,1,0,0,1456,....
The file contains over a million number like this, all on a single line. I would like to split the file into multiple files, with each file containing a fixed number of comma-separated numbers (17577 numbers per file). So the first file will contain the first 17577 comma separated number (from the source file), and the second file will pick up where the first file ended. Ideally each file will end with a number (not the trailing comma) although this isn't critical. If it matters, all of the numbers will be between -2000 and 2000.
I've been trying out methods using bash, like replacing all the commas with line breaks, then using split -l to split up the file, and then replacing all the line breaks back to commas. But I wasn't able to get that to work and am hoping there is a better way. Is there an efficient way to do this?