Welcome to the Make community! [image] samliew: You can map the messages array in the Iterator, then use an Array Aggregator (not Text Aggregator) to select the fields you want. Like I said earlier, this can be done this way. You’ll need a minimum of three modules: [Screenshot_2023-12-20_1… Answer from samliew on community.make.com
🌐
Merge-json-files
merge-json-files.com › json-file-splitter
Split JSON Files Instantly | Free Online JSON Splitter Tool
Use our online tool to split large JSON files into parts easily. Free, safe, and fast — no login or install needed.
Discussions

Is there any sample code to split a json file into smaller chunks?
For example… I got a json file that looks kind of like this: [ { “id:”: 1, “question:”: "What are your hours of operations? ", “answer:”: "We open at 10am and close at 8pm. " }, { “id:”: 2, “question:”: “Do you offer vegetarian food?”, “answer:”: “Yes, we have ... More on community.openai.com
🌐 community.openai.com
0
0
October 17, 2023
text processing - Split a JSON array into multiple files - Unix & Linux Stack Exchange
This takes each top-level array element in your JSON document and creates a shell here-document redirection for each. Each redirection into cat is quoted to avoid that the shell expands things in the document. More on unix.stackexchange.com
🌐 unix.stackexchange.com
python - Split a large json file into multiple smaller files - Stack Overflow
27 Using jq how can I split a very large JSON file into multiple files, each a specific quantity of objects? More on stackoverflow.com
🌐 stackoverflow.com
posix - Split JSON array into separate files/objects - Stack Overflow
The question then becomes what ... with the -c option, and filter the result into awk, which can then allocate the components to different files. See e.g. Split JSON File Objects Into Multiple Files... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

Can I split a JSON array into multiple smaller files?
Yes. If your root element is an array (e.g., containing 10,000 user objects), you can configure the splitter to chunk by array size. For instance, setting the chunk size to 1,000 will output 10 smaller JSON files, each containing a perfectly valid array of 1,000 objects.
🌐
merge-json-files.com
merge-json-files.com › json-file-splitter
Split JSON Files Instantly | Free Online JSON Splitter Tool
What happens if I split a JSON object instead of an array?
If you split a root JSON object (a dictionary of keys to values), the tool will chunk the data by root-level keys. If you have an object with 500 top-level keys and set a chunk size of 100, you will get 5 separate JSON files, each containing an object with 100 of those root keys.
🌐
merge-json-files.com
merge-json-files.com › json-file-splitter
Split JSON Files Instantly | Free Online JSON Splitter Tool
Will the resulting split files still be valid JSON?
Absolutely. A naive text-splitter would just chop the file in half, breaking curly braces and rendering the JSON invalid. Our tool is a structural splitter. It understands the JSON AST (Abstract Syntax Tree), ensuring that every chunk outputted is enclosed with proper brackets/braces and is 100% compliant with the JSON specification.
🌐
merge-json-files.com
merge-json-files.com › json-file-splitter
Split JSON Files Instantly | Free Online JSON Splitter Tool
🌐
Medium
jhsu98.medium.com › how-to-build-a-command-line-json-splitter-72061b0f20a6
How to Build a Command Line JSON Splitter | by Jonathan Hsu | Medium
March 10, 2019 - Okay, next is to set up the data structure for holding the split pieces and the cutoffs for each piece. We’ll use a 2D Array — also known as an Array of Arrays. Think of a 2D Array as a spreadsheet with an Y-axis (number of nested arrays) and an X-axis (size of each nested array). We’ll create the correct number of nested arrays by using a for loop with the calculated number of chunks. To find the cutoff points lets divide the length of the JSON Array by the number of files.
🌐
OpenAI Developer Community
community.openai.com › api
Is there any sample code to split a json file into smaller chunks? - API - OpenAI Developer Community
October 17, 2023 - For example… I got a json file that looks kind of like this: [ { “id:”: 1, “question:”: "What are your hours of operations? ", “answer:”: "We open at 10am and close at 8pm.
🌐
Splunk Community
community.splunk.com › t5 › Getting-Data-In › how-to-split-the-json-array-into-multiple-new-events › m-p › 122265
how to split the json array into multiple new even... - Splunk Community
February 11, 2021 - Does anyone know how to turn a single JSON event with an array of N sub-items into N events, each with one sub-item? ... examples you want....so you probably did not read the docs then there are examples on how to use spath on XML and JSON -> http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Spath#Examples ... Note, you might have to use spath to get multi-value fields, then mvexpand to get events from each distinct set. ... Get Updates on the Splunk Community!
Find elsewhere
🌐
Cloudera Community
community.cloudera.com › t5 › Support-Questions › How-to-split-large-json-file-into-multiple-json-files-in › m-p › 364136
Solved: How to split large json file into multiple json fi... - Cloudera Community - 364136
March 2, 2023 - We have a large json file which is more than 100GB and we want to split this json file into multiple files. We used Split Text processor to split this json file into mutliple files by specifying Line Split Count.
🌐
GitHub
github.com › jhsu98 › json-splitter
GitHub - jhsu98/json-splitter · GitHub
A simple command line tool for splitting large JSON files into smaller files.
Starred by 54 users
Forked by 20 users
Languages   Python
🌐
Quora
quora.com › How-do-I-split-a-single-JSON-object-array-into-two-JSON-arrays
How to split a single JSON object array into two JSON arrays - Quora
Answer (1 of 4): you can split it by using a index of a json array. var lists = [ {name: “sai”, age:”21”}, {name: “siva”, age:”22”} ]; var list1 = lists[0]; var list2 = lists[1];
🌐
GitHub
gist.github.com › abraham › 46875b4b1c4b855cb3d3cafe540a22b2
Split a large JSON file into multiple files · GitHub
Save abraham/46875b4b1c4b855cb3d3cafe540a22b2 to your computer and use it in GitHub Desktop. Download ZIP · Split a large JSON file into multiple files · Raw · example.json · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
Reddit
reddit.com › r/learnpython › split 150gb json file with python?
r/learnpython on Reddit: Split 150GB json file with Python?
March 3, 2024 -

I haven't had much to do with json files so far, but now I need them for datahoarding. Now I have a 150GB json file here and can't open it because there's not enough free HDD & RAM on my laptop and computers.

So I have to split the file into several pieces (prefer 1 GB files) and open and view them one after the other. How can I do this on Windows?

Google spits out ancient results (and mostly for Linux) which, as usual, have contradictory information.

Maybe it is possible with a Python script. I don't care if the last and first line of the new file look slightly different than in the original json file

🌐
DEV Community
dev.to › imaduddin_101 › how-to-split-json-files-fastest-and-easiest-way-e92
How to split JSON files - Fastest and Easiest way - DEV Community
April 11, 2025 - Upload your JSON file – Drag and drop or select a JSON file. Set your splitting preferences – Choose the number of parts or size per file. Click "Split JSON" – Our tool processes it instantly.
Top answer
1 of 3
5

Here is a Python solution to your problem.

Don't forget to change the in_file_path to the location of your big JSON file.

import json

in_file_path='path/to/file.json' # Change me!

with open(in_file_path,'r') as in_json_file:

    # Read the file and convert it to a dictionary
    json_obj_list = json.load(in_json_file)

    for json_obj in json_obj_list:
        filename=json_obj['_id']+'.json'

        with open(filename, 'w') as out_json_file:
            # Save each obj to their respective filepath
            # with pretty formatting thanks to `indent=4`
            json.dump(json_obj, out_json_file, indent=4)

Side Note: I ran this in Python3, it should work in Python2 as well

2 of 3
1

I ran into this problem today as well, and did some research. Just want to share the resulting Python snippet that lets you also customise the length of split files (thanks to this slicing method).

import os
import json
from itertools import islice

def split_json(
    data_path,
    file_name,
    size_split=1000,
):
    """Split a big JSON file into chunks.
    data_path : str, "data_folder"
    file_name : str, "data_file" (exclude ".json")
    """
    with open(os.path.join(data_path, file_name + ".json"), "r") as f:
        whole_file = json.load(f)

    split = len(whole_file) # size_split

    for i in range(split + 1):
        with open(os.path.join(data_path, file_name + "_"+ str(split+1) + "_" + str(i+1) + ".json"), 'w') as f:
            json.dump(dict(islice(whole_file.items(), i*size_split, (i+1)*size_split)), f)
    return

Update: Then, when you need to combine them together again, use the following code:

json_all = dict()
split = 4         # this is the 1-based actual number of splits

for i in range(1, split+1):
    with open(os.path.join("data_folder", "data_file_" + str(split) + "_" + str(i) + ".json"), 'r') as f:
        json_i = json.load(f)
        json_all.update(json_i)
🌐
Reddit
reddit.com › r/bash › splitting a huge json file into several smaller files
r/bash on Reddit: Splitting a huge JSON file into several smaller files
May 27, 2022 -

Hi!

I have a huge JSON file containing company data that I want to split into several smaller files based on their companyId. The JSON file looks like this:

[
    {
        "companyId": "123456789",
        "name": "Foobar Ltd.",
        // more company data
    },

    // etc.
]

Ideally, I want to split this based on the X first characters of companyId, so that I end up with companies that share the first part of their companyId in separate smaller files;

companyId 123456789 => 1234.json
companyId 234567890 => 2345.json
// etc

I could write a Perl script to do this for me, but I was wondering if it's at all possible to do it with a one-liner without too much "outside of bash", if that makes sense, at least without having to rely on Perl, Python etc. The only progress I have made so far is this:

cat huge.json | jq '.[]' | jq '.companyId'

...which outputs the companyId, and I could probably get the X first characters from that, but where is the rest of the JSON record?

Thanks in advance!

EDIT: Specified that I don't want to use Perl (or similar tools), because I want to do this as "minimal" as possible.

Top answer
1 of 4
6
You probably want to look at the --compact-output and --stream flags to jq Parse your big input file with jq, pipe it into a while loop, read the input one line at a time. You can then search each line for the relevant company id and dump the line into the right file as needed. You will probably need some 'glue' around the individual lines to make each individual split json file be valid json afterwards. It might be better to create one json file per companyID at first then merge them all together in a second pass.
2 of 4
5
$ cat company.json [ { "companyId": "123456789", "name": "Foobar1 Ltd." }, { "companyId": "765456788", "name": "BarFoo2 Ltd." }, { "companyId": "123456788", "name": "Barfoo1 Ltd." }, { "companyId": "765456789", "name": "Foobar2 Ltd." } ] You can use group_by() $ jq -c 'group_by(.companyId[:4])[]' company.json [{"companyId":"123456789","name":"Foobar1 Ltd."},{"companyId":"123456788","name":"Barfoo1 Ltd."}] [{"companyId":"765456788","name":"BarFoo2 Ltd."},{"companyId":"765456789","name":"Foobar2 Ltd."}] As for splitting it into separate files - you probably have to call jq multiple times: $ jq -c 'group_by(.companyId[:4])[]' company.json | while read -r line do filename=$(jq -r '.[0].companyId[:4]' <<< "$line").json declare -p filename jq . <<< "$line" done Output: declare -- filename="1234.json" [ { "companyId": "123456789", "name": "Foobar1 Ltd." }, { "companyId": "123456788", "name": "Barfoo1 Ltd." } ] declare -- filename="7654.json" [ { "companyId": "765456788", "name": "BarFoo2 Ltd." }, { "companyId": "765456789", "name": "Foobar2 Ltd." } ]
🌐
Stack Overflow
stackoverflow.com › questions › 42978661 › how-to-split-a-json-object-in-two-and-append-each-separately
jquery - How to split a JSON object in two and append each separately - Stack Overflow
@DarianSteyn you can then define var c = 0; and use that as your count, to check in the condition. Or was posted, use a for loop. ... You were pretty much on the right track - although having this logic inside an each of all the data.rates seems a bit weird. Below is the logic to split an associative array into 2 parts getting the keys & values