<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Timesofasi]]></title><description><![CDATA[Timesofasi]]></description><link>https://timesofasi.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 03 Nov 2026 15:56:37 GMT</lastBuildDate><atom:link href="https://timesofasi.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Merge JSON Files in Python Without Overwriting Keys]]></title><description><![CDATA[Learn how to merge JSON files in Python with deep merge, shallow merge and array merge by ID. Working code examples, plus a free online JSON merge too]]></description><link>https://timesofasi.hashnode.dev/how-to-merge-json-files-in-python-without-overwriting-keys</link><guid isPermaLink="true">https://timesofasi.hashnode.dev/how-to-merge-json-files-in-python-without-overwriting-keys</guid><category><![CDATA[Python]]></category><category><![CDATA[json]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Timesofasi]]></dc:creator><pubDate>Fri, 30 Oct 2026 13:07:29 GMT</pubDate><content:encoded><![CDATA[<p>Merging JSON files sounds easy until you lose data. A plain <code>dict.update()</code> overwrites whole nested objects, and arrays are replaced instead of combined. Here is how to do it properly in Python.</p>
<h2>The problem: shallow merge loses data</h2>
<p>Say you have two config files.</p>
<p><strong>a.json</strong></p>
<pre><code class="language-json">{
  "name": "app",
  "settings": { "theme": "dark", "lang": "en" }
}
</code></pre>
<p><strong>b.json</strong></p>
<pre><code class="language-json">{
  "settings": { "theme": "light" },
  "debug": true
}
</code></pre>
<p>A shallow merge replaces the whole <code>settings</code> object:</p>
<pre><code class="language-python">import json

with open("a.json") as f1, open("b.json") as f2:
    a = json.load(f1)
    b = json.load(f2)

result = {**a, **b}   # or: a | b  (Python 3.9+)
print(json.dumps(result, indent=2))
</code></pre>
<pre><code class="language-json">{
  "name": "app",
  "settings": { "theme": "light" },
  "debug": true
}
</code></pre>
<p>Notice that <code>"lang": "en"</code> is gone. That is the classic shallow merge bug.</p>
<h2>Deep merge: keep nested keys</h2>
<p>A deep merge walks into nested objects and merges them recursively:</p>
<pre><code class="language-python">def deep_merge(a, b):
    result = dict(a)
    for key, value in b.items():
        if key in result and isinstance(result[key], dict) and isinstance(value, dict):
            result[key] = deep_merge(result[key], value)
        else:
            result[key] = value
    return result

merged = deep_merge(a, b)
print(json.dumps(merged, indent=2))
</code></pre>
<pre><code class="language-json">{
  "name": "app",
  "settings": { "theme": "light", "lang": "en" },
  "debug": true
}
</code></pre>
<p>Now <code>lang</code> is kept, and <code>theme</code> is updated by the second file. If both files define the same key, the <strong>last file wins</strong>. Decide this on purpose, since it is the most common source of surprises.</p>
<h2>Merging many files at once</h2>
<pre><code class="language-python">import json
from functools import reduce
from pathlib import Path

files = sorted(Path("configs").glob("*.json"))
data = [json.loads(p.read_text()) for p in files]

merged = reduce(deep_merge, data, {})
Path("merged.json").write_text(json.dumps(merged, indent=2))
</code></pre>
<p>Sorting the files makes the result predictable, because the order decides who wins on conflicts.</p>
<h2>Merging arrays of objects by ID</h2>
<p>Merging two lists usually should not create duplicates. If your objects have an <code>id</code>, merge them by it:</p>
<pre><code class="language-python">def merge_by_id(a, b, key="id"):
    merged = {item[key]: item for item in a}
    for item in b:
        merged[item[key]] = deep_merge(merged.get(item[key], {}), item)
    return list(merged.values())

users_a = [{"id": 1, "name": "Asha"}, {"id": 2, "name": "Ravi"}]
users_b = [{"id": 2, "email": "ravi@example.com"}, {"id": 3, "name": "Meena"}]

print(merge_by_id(users_a, users_b))
# [{'id': 1, 'name': 'Asha'},
#  {'id': 2, 'name': 'Ravi', 'email': 'ravi@example.com'},
#  {'id': 3, 'name': 'Meena'}]
</code></pre>
<h2>Edge cases to watch for</h2>
<ul>
<li><strong>Type conflicts:</strong> one file has an object and the other has a string for the same key. Decide which wins.</li>
<li><strong>Arrays without IDs:</strong> you either replace them, concatenate them, or de-duplicate them. Pick one rule.</li>
<li><code>null</code> <strong>values:</strong> decide whether <code>null</code> should overwrite a real value.</li>
<li><strong>Large files:</strong> <code>json.load</code> reads everything into memory. For very large files, use a streaming parser such as <code>ijson</code>.</li>
<li><strong>Invalid JSON:</strong> wrap <code>json.load</code> in <code>try/except json.JSONDecodeError</code> so one bad file gives a clear error.</li>
</ul>
<h2>Don't want to write code?</h2>
<p>If you just need a quick result, I built a free browser tool for this: <a href="https://www.joinjson.com/"><strong>JoinJSON</strong></a>. You can paste JSON, upload files, or load from a URL, then merge them and download the result.</p>
<p>More guides:</p>
<ul>
<li><a href="https://www.joinjson.com/merge-json-files-python/">Merge JSON files in Python</a></li>
<li><a href="https://www.joinjson.com/deep-merge-vs-shallow-merge-json/">Deep merge vs shallow merge in JSON</a></li>
<li><a href="https://www.joinjson.com/merge-json-arrays-by-id/">Merge JSON arrays by ID</a></li>
</ul>
<p>What edge case has bitten you when merging JSON? Tell me in the comments.</p>
]]></content:encoded></item><item><title><![CDATA[Top Machine Learning Projects for Students to Boost Their Skills]]></title><description><![CDATA[An excellent way to put their newfound skills could by allowing them to work on Machine Learning Projects for Students with Python which will be quite…]]></description><link>https://timesofasi.hashnode.dev/top-machine-learning-projects-for-students-to-boost-their-skills</link><guid isPermaLink="true">https://timesofasi.hashnode.dev/top-machine-learning-projects-for-students-to-boost-their-skills</guid><category><![CDATA[Machine Learning]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[technology]]></category><category><![CDATA[AI]]></category><category><![CDATA[#ai-tools]]></category><dc:creator><![CDATA[Timesofasi]]></dc:creator><pubDate>Sun, 22 Sep 2024 15:56:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1727020430316/82b2eae6-6e8a-4823-8411-06bd2a2dce74.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>An excellent way to put their newfound skills could by allowing them to work on <a target="_blank" href="https://timesofasi.com/data-preprocessing-in-machine-learning-python/">Machine Learning</a> Projects for Students with Python which will be quite exiting opportunity for the students across varied domains. This chapter goes deep inside predictive modeling, which is just scratching the surface of what <a target="_blank" href="https://venturebeat.com/category/ai/">machine learning</a> can do, from predicting electricity consumption to optimizing smart traffic systems. Break, where students run code to analyze datasets and build models, Informing evaluation This module includes instructions for real-world applications on each aspect of analyzing dataset, model constructs, or evaluating performance improvements. Through Python, readers discover the potential for drastically increased system efficiencies and data-oriented concepts and examples: including hands-on examples that can be applied to students’ own projects in class disruption.Comment by consultant Idan Gabriel Case– prompt_content –By understanding the way Python is marked by great gains in effectiveness and practical ways of working with data-driven concepts this book is relevant to all of us.</p>
<h1 id="heading-machine-learning-project-with-source-code"><strong>Machine Learning Project With Source Code</strong></h1>
<p><strong>1.Energy Consumption Forecasting2.Environmental Monitoring and Sustainability3.Automation in Manufacturing4.Smart Traffic Systems</strong></p>
<h1 id="heading-1energy-consumption-forecasting"><strong>1.Energy Consumption Forecasting</strong></h1>
<p>The first use case surrounds machine-learning powered energy consumption forecasting, a process that tries to accurately predict the amount of electricity (and in a broader sense energy) companies will produce, distribute or consume at some point in the future. This is important for city planning, for efficiency in the energy system and a move toward sustainable energy.</p>
<p>Learners will proceed to build basic models for machine learning on historical energy data with reference to factors like weather, time of the day and seasonality to predict energy demand in this section. It introduces readers with a dataset to perform data processing, feature selection and the implementation of a Linear Regression model further showing the influence of machine learning on energy savings.</p>
<h1 id="heading-2-environmental-monitoring-and-sustainability"><strong>2. Environmental Monitoring and Sustainability</strong></h1>
<p>The advantages of machine learning are quite evident right, and these in combination with environmental science provide key tools for addressing the pressing challenges such as climate change, pollution.getResource depletion. The Machine Learning Projects for Students at the property be sending an algorithm to Decision Trees that serves for making predictions by analyzing environmental data. And some have been used to determine air quality and locate pollutants or identify recyclable materials for better waste management, thereby reducing environmental damage.</p>
<p>Machine learning gives us the ability to predict both environmental trends and policies that can move us toward sustainable progress. In experimenting with weather data, pollution index data and also studying recyclable data from their real world datasets, students could seen learn patterns that may be consequential for the future of environmental monitoring and protection.</p>
<h1 id="heading-3-automation-in-manufacturing"><strong>3. Automation in Manufacturing</strong></h1>
<p>Manufacturing Automation is Changing the Way We Design, Build, and Ship Products The move towards extensive digitization is facilitated by the use of machine learning to increase production efficiency, minimize plant downtime and predict maintenance requirements with a much greater degree of certainty. All of this is very important for the tuning of production and the reduced costs.</p>
<p>This section focuses the application of cutting edge machine learning techniques such as Random Forests to predict when individual machines will fail and require maintenance. We will leverage a dataset of machine performance metrics (i.e., temperature, vibration, noise and operational hours) to understand how these factors influence the health score of a machine.</p>
<p>In the Machine Learning Projects for Manufacturing, you will become adept at performing data exploration, feature engineering as well build predictive models using advanced algorithms such Random Forests and Neural Networks that deals with Non-linearly structured data and avoid over fitting. This use case illustrates the future of predictive analytics and how it can predict machine failures for proactive maintenance, thus improving operational efficiency by leveraging innovation in the manufacturing industry.</p>
<h1 id="heading-4-smart-traffic-systems"><strong>4. Smart Traffic Systems</strong></h1>
<p>Smart Traffic Systems A Solution to Urbanization and Growing Car Numbers These systems use machine learning, particularly the neural networks to make sure that traffic does not stop unnecessarily and they avoid congestion ensuring all vehicles are landed safely. Machine learning can be applied to variables such as vehicle speeds, counts and traffic patterns, allowing traffic signals and routes to be controlled in real time.</p>
<p>In this section, we take a different track by exploring the prediction of traffic congestion with feedforward neural networks (FFNN), which offers well-known pattern recognition characteristics of FFNN for Smart Traffic Systems━the improvement of traffic conditions in these systems. By using techniques like k-fold cross-validation and hyperparameter tuning, the models are not only accurate but are also generalizable to a variety of different traffic scenarios.</p>
<p>As models are fine-tuned, Smart Traffic Systems will be able to more efficiently regulate city traffic ensuring better travel and safer roads.</p>
]]></content:encoded></item></channel></rss>