A command-line utility for uploading segment data to Split.io in manageable chunks. Split's Segment Upload API requires segments be broken upinto chunks of 10,000 and so this will take a file to be uploaded as an argument, break it up, and then proceed to upload it in chunks of 10,000 id values.
Note that the segment must already exist in the environment.
This utility script makes it easy to upload large segment files to Split.io's API by:
- Breaking large CSV files into smaller chunks
- Uploading each chunk to the Split.io API
- Cleaning up temporary files after successful uploads
- Bash shell
- curl
- split command (GNU split)
- On macOS, this requires installing GNU coreutils:
brew install coreutils
- On macOS, this requires installing GNU coreutils:
- Clone this repository or download the
upload-segment.shscript - Make the script executable:
chmod +x upload-segment.sh
./upload-segment.sh -k APIKEY -e ENVIRONMENT_ID -s SEGMENT_NAME -f FILE_PATH
| Parameter | Description |
|---|---|
-k |
Split.io Admin API Key |
-e |
Split.io Environment ID |
-s |
Segment Name |
-f |
Path to CSV file containing segment data |
-h |
Show help message |
./upload-segment.sh -k YOUR_API_KEY -e YOUR_ENVIRONMENT_ID -s power_users -f /path/to/users.csvThe CSV file should contain the keys for your segment, with one key per line. For example:
user1@example.com
user2@example.com
user3@example.com
- The script validates that all required parameters are provided
- It checks if the specified file exists
- The file is split into chunks of 10,000 lines each
- Each chunk is uploaded to the Split.io API
- Successfully uploaded chunks are removed automatically
- Any failures are reported, and failed chunk files are preserved for debugging
- If you encounter issues on macOS, ensure you have GNU coreutils installed:
brew install coreutils - Check that your API key has appropriate permissions
- Verify that the segment name is correct and exists in your Split.io environment
- If uploads fail, examine the preserved chunk files to identify any formatting issues