{"slug": "read-one-field-from-a-rida-dataset-with-python-and-node-js", "title": "Read one field from a RIDA dataset with Python and Node.js", "summary": "The maker of RIDA published a tutorial showing how to read a single field from a RIDA dataset by record ID in both Python and Node.js, using the rida-format 3.0.2 package. The example builds a small bilingual Arabic-Urdu records file into a Demo.rida dataset with a companion index, then retrieves the Urdu value for entry-1 via RidaFile.get in Python and RidaReader.get in Node.js, with no second build or JSON export. The author notes the index also supports HTTP byte-range retrieval for remote reads, provided the host supports byte ranges and the reader has the companion index.", "body_md": "I used AI assistance to draft this tutorial. I’m sharing RIDA as its maker.\n\nA bilingual archive gives you a simple reason to read a record one field at a time. When you want the Urdu translation, there is no reason to send the Arabic text and every note along with it. RIDA builds an index over prepared records so a reader can look up a field by record ID. Here is a small example you can reproduce with the same file in Python and Node.js.\n\nUse Python 3.10 or later and Node.js 20 or later. In a fresh directory, save this as `records.json`:\n\n```\n{\n  \"entry-1\": {\n    \"arabic\": \"كتاب\",\n    \"urdu\": \"کتاب\",\n    \"category\": \"glossary\"\n  }\n}\npython3 -m venv .venv\nsource .venv/bin/activate\npython -m pip install rida-format==3.0.2\nrida build records.json Demo.rida --yes\n```\n\nKeep `Demo.rida` and its companion index together. The build writes a dataset to disk. Use a fresh output name for another build.\n\nSave this as `read_demo.py` and run `python read_demo.py` from the same directory.\n\n``` python\nfrom rida import RidaFile\n\nwith RidaFile(\"Demo.rida\") as dataset:\n    print(dataset.get(\"entry-1\", \"urdu\"))\n```\n\nExpected output is `کتاب`. You can fetch both values in one call with `dataset.get_many(\"entry-1\", [\"arabic\", \"urdu\"])` inside the `with` block.\n\nInstall the Node reader with `npm install rida-format@3.0.2`. Save the following as `read_demo.mjs`, then run `node read_demo.mjs`.\n\n``` js\nimport { RidaReader } from \"rida-format\";\n\nconst reader = await RidaReader.open(\"./Demo.rida\");\ntry {\n  console.log(await reader.get(\"entry-1\", \"urdu\"));\n} finally {\n  await reader.close();\n}\n```\n\nYou should see the same `کتاب`. Both programs read the same data and index. There is no second build or intermediate JSON export.\n\nThe lookup still starts with a record ID and a field name. The index lets the reader find the stored value, then the remote reader can use HTTP byte-range requests to retrieve the relevant bytes. Your host needs to support byte ranges, and your reader needs the companion index. Check the remote setup in the guides before deploying. If you enable encryption on a real dataset, provide its key when reading and keep it separate from public files.\n\nThis approach fits prepared, read-heavy collections where your app already knows the record ID. Full-text search is a separate job. For a catalogue, one practical setup is to find an ID in the search layer and use that ID to fetch its display fields from RIDA.\n\nThe [RIDA repository](https://github.com/Qasraf/rida) has a larger public sample and the [Python](https://github.com/Qasraf/rida/blob/main/docs/PYTHON.md) and [Node.js](https://github.com/Qasraf/rida/blob/main/docs/NODE.md) guides. I wrote more about the bilingual archive that prompted this example in [RIDA by QASRA on Medium](https://medium.com/@chishty_50304/rida-by-qasra-and-the-case-for-reading-one-record-at-a-time-1b2521a175cc).", "url": "https://wpnews.pro/news/read-one-field-from-a-rida-dataset-with-python-and-node-js", "canonical_source": "https://dev.to/hamza_chishty_2c78e3ebc98/read-one-field-from-a-rida-dataset-with-python-and-nodejs-11me", "published_at": "2026-12-04 20:11:04+00:00", "updated_at": "2026-12-04 20:13:39.222866+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["RIDA", "QASRA", "Python", "Node.js", "rida-format"], "also_reported_by": [], "takeaway": "RIDA's index lets a reader fetch a single field by record ID in Python (RidaFile.get) or Node.js (RidaReader.get) from the same built dataset, and remote reads use HTTP byte-range requests requiring host support and the companion index.", "recommendation": {"advice": "For prepared, read-heavy collections where the record ID is already known, build a RIDA index and fetch only the needed fields instead of loading whole records; keep the companion index with the dataset and confirm byte-range support before remote reads.", "playbook": "rag-retrieval", "playbook_url": "https://wpnews.pro/playbooks/rag-retrieval"}, "alternates": {"html": "https://wpnews.pro/news/read-one-field-from-a-rida-dataset-with-python-and-node-js", "markdown": "https://wpnews.pro/news/read-one-field-from-a-rida-dataset-with-python-and-node-js.md", "text": "https://wpnews.pro/news/read-one-field-from-a-rida-dataset-with-python-and-node-js.txt", "jsonld": "https://wpnews.pro/news/read-one-field-from-a-rida-dataset-with-python-and-node-js.jsonld"}}