Load the practice collection
Run once in mongosh against a development instance with an empty tagImports practice collection.
const lab = db.getSiblingDB("keplergrid_practice")
lab.tagImports.insertMany([
{ _id: "a", tagsText: " ink, paper, , pen " },
{ _id: "b", tagsText: "notebook" },
{ _id: "c" }
])
In KeplerGrid, open keplergrid_practice.tagImports with a Read only connection.
Split, trim, and remove empty tokens
Paste the pipeline into Aggregation → JSON and run it. This example expects a string or a missing value. It uses an empty string as the input when the field is null or missing.
[
{ "$set": { "tags": {
"$filter": {
"input": { "$map": {
"input": { "$split": [{ "$ifNull": ["$tagsText", ""] }, ","] },
"as": "part",
"in": { "$trim": { "input": "$$part" } }
} },
"as": "tag",
"cond": { "$ne": ["$$tag", ""] }
}
} } },
{ "$sort": { "_id": 1 } }
]
The arrays contain ["ink", "paper", "pen"], ["notebook"], and []. Without a delimiter, splitting returns an array containing the original string.
Check the source format before reusing the pipeline
Compare the original tagsText field with tags in KeplerGrid. This works for simple delimited fields. For quoted CSV with embedded commas, use a CSV parser or KeplerGrid’s CSV import workflow.
See how to compare the cleaned tags with another list or revisit the related KeplerGrid walkthrough.