<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mridul Dixit on Medium]]></title>
        <description><![CDATA[Stories by Mridul Dixit on Medium]]></description>
        <link>https://medium.com/@mriduldixit19?source=rss-c656e8b8729b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1neTU8VsmQd8sUB-.jpg</url>
            <title>Stories by Mridul Dixit on Medium</title>
            <link>https://medium.com/@mriduldixit19?source=rss-c656e8b8729b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:10:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mriduldixit19/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Time never remains the same]]></title>
            <link>https://medium.com/@mriduldixit19/time-never-remains-the-same-363c669daf97?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/363c669daf97</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 21:53:53 GMT</pubDate>
            <atom:updated>2024-11-28T22:12:13.652Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the famous quotes “Time never remains the same “. Its easy to console someone by saying that <em>“every dark night is followed by bright sunlight”</em>. People say its easy to comment on other’s situation but hard to deal with the situation when it comes to themselves, when they are the main character in that hardship story. But the quote remains true, however way you may perceive it.</p><p>We have high propensity to dwell in those hard situations, by overthinking, making sure we remember it every moment like it belongs to us, Isn’t it kind of venerating the thing that we hate?</p><p>With all these years of life experience, we know at heart that situation wont remain the same, still we tend to live it every moment, usually overthinking, worrying! Ever thought why we dont react the same way, “overthinking” when it comes to some Happy Good News?</p><p>When was the last time when you were constantly overthinking on some good news, day and night? Interesting right? Hard to recall anything as such!</p><p>What do they call this symptom of constantly remaining in happy mood? I think we need to google it. But the irony is that we dont need to even ask a person beside us about that what they call the symptom which indicates the person who remains sad for hours, months, years. Yes! that is so true — Depression. I believe the human psychology is to react despairingly at the worst situations and react casually on the best ones. They might find it mandatory to react, maybe something like that ?</p><p>I would like to request readers to go back down their memory lane, and think of the time when they had been through the worst situation and how long they had been affected by it. Do you think it was worth utilizing that time, being depressed, hopeless, lost to the world? I believe, these following adjectives (once used when you were low) cant be used to describe you at this very moment. Can you think why this cant be used to describe you even now? I am sure I made my point. :)</p><p>Because time never remains the same.</p><p>I wont say that it’s wrong to react at the worst situations, one would surely react and thats what makes us human! I have been through that phase, everyone does have their stories and experiences and that experience led me to grow to a better version of myself and also coerced me to write this :p I thought there might be people who doubt this quotation.</p><p>My point is , it depends on us how to react and for how long? For how long, so that it dont exacerbate the situation. So that it dont perturb one’s confidence. So that it dont let someone forfeit one’s patience. As someone once well said, “ When you are already in hole, stop digging.”</p><p>Digging one’s thought, guilt or reiterating the vain words will not console your broken soul , it will only lead you farther to the place you are struggling to escape from.</p><p>I would only say that worst situations may come, surely come but its also true that you will be THE one, standing by the door who will surely have the choice to welcome it wholeheartedly with positiveness without letting it plunder your patience , confidence and hope and escort it kindly after interacting with it. Or else you can invite it cordially to stay at your mind, thoughts for years , pillaging your dreams and essential qualities and letting you be depressed and making you think “Athiti Tum Kab Jaoge”. Even at that time (when long time has passed away) , you will have the option to discard it off but only difference will be that the “Atithi “ will be leaving you bare handed, robbed all your confidence, patience and hope.</p><p>You see, time changed again , again just by YOUR actions.</p><p>In the end, the choice is always ours. Time, as it flows relentlessly, will continue to bring challenges, but it also brings the gift of change. The way we choose to navigate through these moments defines not just how we survive, but how we grow. Yes, we will face pain, loss, and adversity — but we also have the power to decide how long we allow them to linger in our minds and hearts.</p><p>The darkness will eventually fade, and with it comes a new dawn, brighter than before. Time never remains the same, and neither do we. The real question is: How will you choose to change with it? Will you let the hard moments define you, or will you use them as stepping stones towards something greater?</p><p>Remember, even in the worst of times, you have the power to shape your future. You can be the one who chooses to let go of what no longer serves you, to embrace what’s ahead with hope, and to rise stronger with each passing day.</p><p>Time may never remain the same, but you have the strength to remain resilient. The choice, ultimately, is yours…..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MSFboZeSTfrtudXT-eCSeg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=363c669daf97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MuleSoft DataWeave Part -3]]></title>
            <link>https://medium.com/@mriduldixit19/dataweave-part-3-zip-unzip-and-flatten-7fb621e98f2f?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fb621e98f2f</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 20:47:30 GMT</pubDate>
            <atom:updated>2024-04-20T09:41:35.777Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I’d like to walk you through various transformations that can be performed in DataWeave like zip, unzip, flatten etc</p><h3>Zip :</h3><p>Merges elements from two arrays into an array of arrays.</p><h4>Syntax :</h4><h3>zip&lt;T, R&gt;(left: Array&lt;T&gt;, right: Array&lt;R&gt;): Array&lt;Array&lt;T | R&gt;&gt;</h3><p>left : The array on the left-hand side of the function.</p><p>right : The array on the right-hand side of the function.</p><p>We have two arrays namely employeeNames and country they belong to. Here the idea is to group the employee with their country in one array, for this we will use zip function</p><p><strong>DataWeave syntax</strong></p><pre>%dw 2.0<br>output application/json<br>var employeeNames = [&quot;Mridul&quot;, &quot;Piotr&quot;, &quot;John&quot;]<br>var country = [&quot;IN&quot;,&quot;PL&quot;,&quot;CA&quot;]<br>---<br>{<br>    employeeDetails : zip (employeeNames, country),<br>   // employeeDetails : employeeNames zip country (Both are same)<br>}</pre><p><strong>Output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dn6fclY7EPXt5lUAkbrZUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDew9K3ItcbfYaLTnu760w.gif" /></figure><h3>Unzip :</h3><p>It takes an array of arrays as input and does the opposite of zip function</p><h4>Syntax :</h4><h3>unzip&lt;T&gt;(items: Array&lt;Array&lt;T&gt;&gt;): Array&lt;Array&lt;T&gt;&gt;</h3><p><strong>DataWeave Syntax :</strong></p><pre>%dw 2.0<br>output application/json<br>var employeeNames = [&quot;Mridul&quot;, &quot;Piotr&quot;, &quot;John&quot;]<br>var country = [&quot;IN&quot;,&quot;PL&quot;,&quot;CA&quot;]<br>---<br>{<br>    employeeDetails : unzip(zip (employeeNames, country))<br>}</pre><p><strong>Output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fK_XdsHC-g8KPG1dTktvLQ.png" /></figure><h4>Example 2 :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kgA8HB1uKtRHjvE50lizVQ.png" /></figure><h3>Flatten :</h3><p>Convert the array of arrays into a single array with all values.</p><h4>Syntax :</h4><h3>flatten&lt;T, Q&gt;(@StreamCapable items: Array&lt;Array&lt;T&gt; | Q&gt;): Array&lt;T | Q&gt;</h3><p>Dataweave :</p><pre>%dw 2.0<br>output application/json<br>var fruits = [<br>                  [<br>                     &quot;fruit&quot; : &quot;orange&quot;,<br>                     &quot;fruit&quot; : &quot;apple&quot;<br>                  ],<br>                  [<br>                     &quot;fruit&quot; : &quot;grape&quot;,<br>                     &quot;fruit&quot; : &quot;kiwi&quot;<br>                  ]<br>               ]<br>---<br>{<br>    FruitInfo: flatten (fruits)<br>}</pre><p><strong>Output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pdk2EPfQK3lUDAoh8BGqIw.png" /></figure><blockquote>Explore more on DataWeave : <a href="https://medium.com/@mriduldixit19/mulesoft-dataweave-part-1-3c675f3887e8">MuleSoft DataWeave — Part 1</a></blockquote><blockquote>Explore more on DataWeave : <a href="https://medium.com/@mriduldixit19/mulesoft-dataweave-part-2-baf0e9e4c68c">MuleSoft DataWeave — Part 2</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fb621e98f2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MuleSoft DataWeave — Part 2]]></title>
            <link>https://medium.com/@mriduldixit19/mulesoft-dataweave-part-2-baf0e9e4c68c?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/baf0e9e4c68c</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 18:43:34 GMT</pubDate>
            <atom:updated>2024-04-20T09:45:08.481Z</atom:updated>
            <content:encoded><![CDATA[<h3>MuleSoft DataWeave — Part 2</h3><p>This blog will help in resolving various “how to” queries related to usecases like map function, write variables inline , perform null check etc</p><h4>1. How to use Map function to iterate over items in an array and outputs the results into a new array</h4><p>Here initially the structure is as following.</p><h4>Input :</h4><pre><br><br>{&quot;employees&quot;:[    <br>    {&quot;name&quot;:&quot;Ram&quot;, &quot;email&quot;:&quot;ram@gmail.com&quot;, &quot;age&quot;:23},    <br>    {&quot;name&quot;:&quot;Shyam&quot;, &quot;email&quot;:&quot;shyam23@gmail.com&quot;, &quot;age&quot;:28}  <br>]}  </pre><p>Now using map function, we can transform the structure by iterating over the given array and create a new array with new structure, where we can have additional fields like “MoreInfo” included as well</p><h4>Map function Syntax :</h4><p><strong>map&lt;T, R&gt;(items: Array&lt;T&gt;, mapper: (item: T, index: Number) -&gt; R): Array&lt;R&gt;</strong></p><p>items : array to map</p><p>mapper : Expression used to act on each item and optionally, each index of that item.</p><h4>Dataweave</h4><pre>%dw 2.0<br>output application/json<br>---<br>payload.employees map (item, index) -&gt;<br>{<br>   &quot;Name&quot; : item.name,<br>   &quot;Age&quot; : item.age,<br>   &quot;MoreInfo&quot;:<br>   {<br>   &quot;Email Address&quot; : item.email,<br>   &quot;EmployeeIndex&quot;: index<br>   }<br>}</pre><h4>Output</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJn9ExAU3Ir9N7ganlFR7w.png" /></figure><h4>Output structure</h4><pre> {<br>    &quot;Name&quot;: &quot;Ram&quot;,<br>    &quot;Age&quot;: 23,<br>    &quot;MoreInfo&quot;: {<br>      &quot;Email Address&quot;: &quot;ram@gmail.com&quot;,<br>      &quot;EmployeeIndex&quot;: 0<br>    }<br>  }</pre><p>Here we can see new Output structure which includes Name, Age, MoreInfo fields etc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bg8hTFKLdnbwqoRPPL0VdQ.gif" /></figure><h4>2. How to use variables inline :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64IyX900CzNm7ri9iEABmA.png" /></figure><pre>%dw 2.0<br>output application/json<br>var firstName = &quot;Mridul&quot;<br>var lastName = &quot;Dixit&quot;<br>---<br>{<br>   FullName : firstName  ++ lastName,<br>   FullNameWithSpace : firstName ++ &quot; &quot; ++ lastName,<br>   Name: &quot;Hi This is $(firstName) $(lastName)&quot;<br><br>}</pre><h4>3. How to perform Null check</h4><p>isEmpty() is a dataweave core function that can be used to perform null check In Mule 4 , it returns Boolean response (true or false)</p><p>It works on Array,String and Object and gives the result accordingly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-yKT5ZrmkOjVkumGCbfAw.png" /></figure><ul><li><strong>var arr = [“1”,”2&quot;,”3&quot;]</strong></li></ul><p>Here array is not empty, hence isEmpty(arr) is false</p><ul><li><strong>var str = “” //Blank string</strong></li></ul><p>Here string is empty, hence isEmpty(str) is true</p><ul><li><strong>var space = “ “ //space</strong></li></ul><p>Here string is space and it is considered as string (not empty), hence isEmpty(space) is false</p><ul><li><strong>var object = {“name” : “Mridul”, “surname” : “Dixit”}</strong></li></ul><p>Here object is not empty, hence isEmpty(object) is false</p><ul><li><strong>var blankObject = “”</strong></li></ul><p>Here object is empty, hence isEmpty(object) is true</p><h4>4. How to count the length of the string or array</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pdKYvzWIb-Zg0rZmjrRiAg.png" /></figure><pre>%dw 2.0<br>output application/json<br>var firstName = &quot;Mridul&quot;<br>var lastName = &quot;Dixit&quot;<br>var arr = [1,5,12]<br>---<br>{<br>   count : sizeOf(firstName),<br>   countArray : sizeOf(arr)<br><br>}</pre><h4>5. How to find the type of data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lltKwbJ_QLtSax-_QsTWQQ.png" /></figure><pre>%dw 2.0<br>output application/json<br>var firstName = &quot;Mridul&quot;<br>var lastName = &quot;Dixit&quot;<br>var arr = [1,5,12]<br>---<br>{<br><br>   typeArray : typeOf(arr),<br>   typeName : typeOf(firstName)<br><br>}</pre><p><em>Explore more on DataWeave : </em><a href="https://medium.com/@mriduldixit19/mulesoft-dataweave-part-1-3c675f3887e8"><em>MuleSoft DataWeave — Part 1</em></a></p><p><em>Explore more on DataWeave : </em><a href="https://medium.com/@mriduldixit19/dataweave-part-3-zip-unzip-and-flatten-7fb621e98f2f"><em>MuleSoft DataWeave — Part 3</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baf0e9e4c68c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MuleSoft Dataweave — Part 1]]></title>
            <link>https://medium.com/@mriduldixit19/mulesoft-dataweave-part-1-3c675f3887e8?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c675f3887e8</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 18:13:05 GMT</pubDate>
            <atom:updated>2024-04-20T09:39:52.383Z</atom:updated>
            <content:encoded><![CDATA[<h3>MuleSoft Dataweave — Part 1</h3><p>Dataweave is a programming language specifically designed by MuleSoft to access and transform data.</p><p>Mule runtime is responsible for running the script and expressions in our Mule application, DataWeave is strongly integrated with Mule runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o9t4vbR-API88iByURzbMw.png" /></figure><p>Dataweave structure :</p><p>DataWeave scripts and files are divided into two main sections:</p><ol><li><strong>Header </strong>: The DataWeave header contains the directives, which define high level information about your transformation. The structure of the Header is a sequence of lines, each with its own Directives. The Header is terminated with ‘ — — — ’</li></ol><p><strong>%dw</strong> — this directive supports the specification of a previous DataWeave version on a per script basis. Use of this directive is optional. The default version is 2.0 if the directive is not present.</p><p>eg: <strong>%dw 2.0</strong></p><p><strong>output </strong>— Commonly used directive that specifies the mime type that the script outputs.</p><p>eg: <strong>output application/xml</strong> specifies that the output will be XML format</p><p><strong>2. Body </strong>: The Dataweave Body contains the expression to generate the output structure. MuleSoft provides a canonical way to work on data with the DataWeave model — a query, transform, build process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVwvBSEl1GTQexO2ZNZ3SA.jpeg" /></figure><p>Lets play around a bit…</p><blockquote><a href="https://dataweave.mulesoft.com/learn/"><em>Click here to Try DataWeave code</em></a></blockquote><p>Use the following Input which is in JSON format</p><p>Input</p><pre>{<br>   &quot;fullName&quot; : &quot;Mridul Dixit&quot;<br>}</pre><p>Lets try to convert this input to different format . for eg: XML</p><p>To do this, write the following dataweave :</p><pre>%dw 2.0<br>output application/xml<br>---<br>payload</pre><p>Yayy!!! Did you see the power of Dataweave with simple example!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kub7MmTBDOzr6GLxpi1ixw.png" /></figure><p>So now the whole JSON response is converted to XML format by just changing the output to <strong>application/xml from application/json</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XztEQKvAqRYLPiYAYP3_7Q.gif" /></figure><h4>How to :</h4><ol><li>Define a variable as an array of numbers and print :</li></ol><pre>%dw 2.0<br>output application/json<br>var arr = [1,10,22,3,25,8,12]<br>---<br>{<br>    printArray : arr<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nx0rOjFvn96uY3G1O_16Dw.png" /></figure><p>2. Arrange the numbers in ascending order</p><pre>ascArray : arr orderBy $</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8TWp3-qQK9Vx50FeT0SMvw.png" /></figure><p>3. Arrange the array in descending order</p><pre>descArray : arr orderBy -$</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2RU_ow-PM4uJRX2OF9IhqQ.png" /></figure><p>4. Check if the descArray contains number — 25 in it</p><pre> containsNumber : arr orderBy -$ contains 25</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dnd1DNUFIF5MY16rLkOltg.png" /></figure><p>5. Concatenate two arrays</p><pre>%dw 2.0<br>output application/json<br>var arr = [1,10,22,3,25,8,12]<br>var names = [&quot;Mridul&quot;, &quot;Ram&quot;, &quot;Rohit&quot;]<br>---<br>{<br>    concatArray : arr ++ names<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tlx8uJiWdNU3JCMaTFXhFQ.png" /></figure><p>6. Remove element “Rohit” from concatenated array</p><pre> removeElement : arr ++ names -  &quot;Rohit&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oww6_qzhlhvAV4G3e_lZXg.png" /></figure><blockquote>Explore more on DataWeave :<a href="https://medium.com/@mriduldixit19/mulesoft-dataweave-part-2-baf0e9e4c68c"> MuleSoft DataWeave — Part 2</a></blockquote><blockquote>Explore more on DataWeave : <a href="https://medium.com/@mriduldixit19/dataweave-part-3-zip-unzip-and-flatten-7fb621e98f2f">MuleSoft DataWeave — Part 3</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c675f3887e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Basics]]></title>
            <link>https://medium.com/@mriduldixit19/python-basics-c60756e63501?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c60756e63501</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Mon, 18 Mar 2024 18:19:31 GMT</pubDate>
            <atom:updated>2024-03-18T18:20:58.679Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iHkoxcsdUQpxtNfChkGvPg.jpeg" /></figure><p>To check if you have python installed on a Windows PC, search in the start bar for Python or run the following on the Command Line (cmd.exe):</p><pre>python --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ao1HUkvb2iFA8l4ZCjleyQ.png" /></figure><p>Getting started :</p><ol><li>In Notepad, write the python code. Lets start with printing the statement.</li></ol><p><strong>print (“This is Mridul Dixit”)</strong></p><p>and save it with filename.py (eg : first_code.py)</p><p>2. Then to execute this file, open the cmd and type : <strong>python first_code.py (Here first_code.py is the fileName)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPxsVbHE2KM9LbnMy9rsaw.png" /></figure><p>Voilaa!! You just created and executed the python command successfully!!</p><h3>Another way :</h3><p>We can write python commands in Command line as well and execute it.</p><ol><li>Open cmd, write <strong>python </strong>and then enter and then start writing the code</li></ol><pre>python<br>&gt;&gt; print (&quot;Hey, This is Mridul Dixit&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFODbWNxGvBpkDlrnflIrA.png" /></figure><p>To quit the python command line interface, type <strong>exit()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5WWkF6Si20gzJK1paWXPg.png" /></figure><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><ol><li>Print a statement</li></ol><p>print(“XXXX”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QFJvLNwaQZiQ4IfCag_Vg.png" /></figure><p>2. Python uses <strong>#</strong> to write a comment.</p><pre>#print(&quot;This is Comment&quot;)<br>print(&quot;Hey, this is Mridul Dixit&quot;)</pre><p>As a result, statement starting with # was not printed as its considered as a comment in python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7mABfxjHX7zt2wL4AmTdw.png" /></figure><p>3. Multiline comment can be given by using # in all lines</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Y1mxIQUzfsBQFvPs1OJAg.png" /></figure><p>4. Variables : Variables do not need to be declared with any particular datatype, and can even change type after they have been set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GiXyDPh4JUCtxrGPXNgggg.png" /></figure><p>Here x = 12 was an integer and then we assigned the value as string (x = “Test”)</p><p>5. How to print multiline code in python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DxrnvdfPsR2hlvSFJKQnrQ.png" /></figure><p>6. By Casting, we can assign the datatype to the variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uAsb94B532avuo1BhxYxFQ.png" /></figure><p>7. How can we get the datatype of the variable — type()</p><pre>&gt;&gt;&gt; x = str(2)<br>&gt;&gt;&gt; print(type(x))<br>&lt;class &#39;str&#39;&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1p_3r8QiZ4Fo-hzFswNLPw.png" /></figure><p>8. How to assign values to multiple variables in one line</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ghetdh14FF8f86Vj8KCEvw.png" /></figure><p>Make sure the number of variables matches the number of values, or else you will get an error.</p><p>9. How to assign one value to multiple variables in one line</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IdVUDaIZILPpFlyKHivq2A.png" /></figure><p>10. How to use print() to output multiple variables at the same time</p><p><strong>One way :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_olvEaDJXSs_V1JhhjY3A.png" /></figure><p><strong>Another way :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jeAVvNQUDye7Z6hivnExw.png" /></figure><p>11. <strong>+ operator</strong> also act as addition in case of variables defined as number</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nVJo8vcy920Bb_kTaadygg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VQtUVWM6plB8JCSs" /><figcaption>Photo by <a href="https://unsplash.com/@sunnystate?utm_source=medium&amp;utm_medium=referral">Reuben Juarez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c60756e63501" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log Kya Kahenge !!!]]></title>
            <link>https://medium.com/@mriduldixit19/log-kya-kahenge-7be9cf5b12c4?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7be9cf5b12c4</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 08:30:25 GMT</pubDate>
            <atom:updated>2023-08-13T18:14:50.886Z</atom:updated>
            <content:encoded><![CDATA[<h3>What will people say? (Log Kya Kahenge)</h3><p>Well, If you are an Indian, you might be well acquainted with the most common cliché “Log kya Kahenge”. I am bit sure you might have some memories related to it. The following three words have the capability to cut out the roots of could-be stout, leafy, grand tree which could provide shade to some people at times. Not only this, these words are strong enough to impede the progression of the society.</p><p>NO! it does not stop here , following words also have immense effect on individual level, it has killed many dreams than anything else in the world. The Dreams, which could be once an inspiring story for some people. The Dreams, which could be the reason for someone’s satiate, beatific smile. The Dreams, which could be — a hope to live , in future.</p><p>I think we have taken the definition of “ human being “ quite seriously , i.e Human beings are socially DEPENDENT species. Well, in my dictionary, dependency never meant the deprivation of thoughts or ideas or dreams by depending on people’s opinion. Some of instances I have came across :</p><p>A house wife wants to change her dressing style, she wants to wear jeans instead of sari. But she give away her desire, thinking “ Log kya Kahenge “.</p><p>A girl is coerced by her parents to learn household job as the same culture prevails “Log Kya Kahenge”.</p><p>Son or daughter is unmarried. Parents are worried about “ “</p><p>A woman being harassed by the in-laws for years, don’t raise voice against them, thwarted by the thought of social stigma.</p><p>Parents know their daughter is being ill treated at her place but are worried to bring back home with an excuse “ (you can already fill the blank)“</p><p>A boy want to marry a girl of different caste, his parents know the selection of his choice is good, but still hesitate to approve of the marriage , thinking</p><p>“Log Kya Kahenge”</p><p>The most stupendous case of all times is that people are afraid to admit their mental illness because of the stigma attached to psychiatric disorders.</p><p>One which we all can relate to is that People are afraid to articulate their opinions when it comes to speak in public , thinking “ “ ( you know that , I believe readers are quite fast learners)</p><p>I would admit that I had been in that league too.</p><p>I believe everyone has a face off with this “Log Kya Kahenge” syndrome, once in a while, but that’s just an excuse we put forward in our path to achieve something. Words are the most common drug used by the mankind , it can be a toxin as well as a panacea. Let no vain word deceive us.</p><p>Whatever the action may be, onlookers will comment. We should never forget “Kuch to Log Kahenge” because “Logon Ka Kaam hai kahna”. The most interesting part is that “Log” who will comment has nothing to do with the thing. My point is its on us , we can be dreamers affected with Lok Kya kahenge Syndrome or we can be dreamers , kicking off this syndrome , choosing the path our heart wants to follow , thinking out of the box and be the leader of our destiny . We just cant let the public opinion or approval take precedence over personal happiness.</p><p>I read it somewhere and it got etched up in my mind “Your goals are not strong enough if people don’t laugh at them”. So next time, do notice if people don’t laugh at you , think twice :)</p><p>Because in the end , on our deathbed, we will surely be thinking of what we did, achieved, experienced and thought rather than what others did, achieved, experienced or thought.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7be9cf5b12c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MuleSoft : All about JSON TO CSV conversion]]></title>
            <link>https://medium.com/@mriduldixit19/mulesoft-all-about-json-to-csv-conversion-861c8f37971c?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/861c8f37971c</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 11:25:21 GMT</pubDate>
            <atom:updated>2023-06-23T11:56:20.744Z</atom:updated>
            <content:encoded><![CDATA[<h3>MuleSoft : All about JSON TO CSV transformation</h3><p>Many integrations require transformations from one file format to another. In this blog, I’d like to walk you through on how to convert json to csv format and we will discuss various usecases related to transforming data, retrieving the values and writing in csv file</p><p>Trust me! You will be mesmerized by the power of DataWeave while going through this doc on seeing how easily by writing few simple dataweave scripts, you will be able to smoothly transform big JSON structured Input to CSV Output.</p><p>Lets first talk about what is JSON and CSV file format that we come across commonly in day to day scenarios while exchange of data files.</p><h3>What is JSON format?</h3><p>JSON or JavaScript Object Notation is an open standard file format for sharing data that uses human-readable text to store and transmit data.</p><ul><li>It has been extended from the JavaScript scripting language.</li><li>The Internet media type for JSON is application/json.</li><li>The JSON filename extension is .json</li><li>It is language independent</li></ul><p>Simple Example of JSON format :</p><p>JSON data is written as name/value pairs (key/value pairs).</p><pre>{<br>   &quot;book&quot;: [<br> <br>      {<br>         &quot;id&quot;:&quot;01&quot;,<br>         &quot;language&quot;: &quot;Java&quot;,<br>         &quot;edition&quot;: &quot;third&quot;,<br>         &quot;author&quot;: &quot;Herbert Schildt&quot;<br>      },<br> <br>      {<br>         &quot;id&quot;:&quot;02&quot;,<br>         &quot;language&quot;: &quot;C++&quot;,<br>         &quot;edition&quot;: &quot;second&quot;,<br>         &quot;author&quot;: &quot;E.Balagurusamy&quot;<br>      }<br>   ]<br>}</pre><h3>What is CSV format?</h3><p>CSV stands for Comma Separated Values, its another kind of file format which is plain text files that contain records of data with comma separated values. Each line in a CSV file is a new record from the set of records contained in the file.</p><ul><li>A CSV (comma-separated values) file is a text file that has a specific format which allows data to be saved in a table structured format.</li><li>A flat file format describing values in a table.</li><li>In this each data is separated by comma, however the last data is not separated by comma</li><li>CSV files don’t always use commas to separate information. A semicolon, space, or a different character might separate the pieces of information. However, the most common character is the comma.</li><li>The Internet media type for CSV is text/csv.</li><li>The CSV filename extension is .csv</li></ul><p>Simple Example of CSV format:</p><pre>Login email;Identifier;First name;Last name<br>laura@example.com;2070;Laura;Grey<br>craig@example.com;4081;Craig;Johnson<br>mary@example.com;9346;Mary;Jenkins<br>jamie@example.com;5079;Jamie;Smith</pre><p>So now that we are well accustomed with different file formats, lets make use of it and see how we can transform one file format to another by the magic of DataWeave. We will perform some more operations while converting it to CSV format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eE-oXWpDO6ACJDmMraQCrA.jpeg" /></figure><p>You can the following JSON input to solve the usecases :</p><pre>[{<br>&quot;First Name&quot;: &quot;Mridul&quot;,<br>&quot;Last Name&quot;: &quot;Dixit&quot;,<br>&quot;Sex&quot;: &quot;Female&quot;,<br>&quot;EmployeeID&quot;: &quot;123456&quot;,<br>&quot;email_address&quot;: &quot;mridul.dixit@gmail.com&quot;,<br>&quot;country&quot;: &quot;India&quot;<br>},<br>{<br>&quot;First Name&quot;: &quot;John&quot;,<br>&quot;Last Name&quot;: &quot;Downey&quot;,<br>&quot;Sex&quot;: &quot;Male&quot;,<br>&quot;EmployeeID&quot;: &quot;12236&quot;,<br>&quot;email_address&quot;: &quot;robert.downey@gmail.com&quot;,<br>&quot;country&quot;: &quot;Germany&quot;<br>}]</pre><blockquote>You can validate the json format in following validator : <a href="https://jsonlint.com/">JSON validator</a></blockquote><p>Lets start with first usecase !!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*QB6gbgRI8djQvWa4df2Hkg.jpeg" /></figure><blockquote><a href="https://dataweave.mulesoft.com/learn/">Click here to Try DataWeave code</a></blockquote><h4>Convert json file format to CSV file format</h4><p>In this usecase, we are trying to convert to given input Json format to csv format. This procedure uses the output directive to produce CSV output from given JSON input.</p><p><strong>Dataweave </strong>:</p><pre>%dw 2.0<br>output application/csv<br>---<br>payload</pre><p><strong>Expected Output -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4zjMODWa_8-7mkGFIduwg.png" /></figure><p><strong>In case we need to add quotes in headers part, the way its shown in below output</strong></p><p><strong>Expected output :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gGRW6H9yJYIJNtMfYVU1w.png" /></figure><p>Now to add quotes in header , we can use <strong>quoteHeader </strong>properties in output directive</p><pre>%dw 2.0<br>output application/csv quoteHeader = true<br>---<br>payload</pre><p>In case we need the following output where values are also in quotes :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7f7_AFyrMxCcW-D2Zhbq0g.png" /></figure><p>Now to add quotes in header , we can use <strong>quoteValues </strong>properties in output directive</p><pre>%dw 2.0<br>output application/csv quoteHeader = true, quoteValues = true<br>---<br>payload</pre><p>Yayy!! You have come a long way and gained knowledge on one of the file format conversion! Hang on to learn few more DataWeave magic tricks :)</p><p>As we talked about that in CSV files, <strong>comma </strong>is the widely used separator but it is not necessary to use comma only, space, semi colon or a line can also be used to separate data in a record. So lets see how we can implement the same as per requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0Pk3SrZXXCtBY7J62YbJg.png" /></figure><p>Here we have used <strong>(|) pipe as separator. </strong>This can be achieved by using <strong>separator </strong>property in output directive.</p><pre><strong>%dw 2.0<br>out</strong>put application/csv quoteHeader = true,quoteValues = true,separator = &quot;|&quot;<br>---<br>payload</pre><p>Similary, if we want to use <strong>semicolon </strong>as separator the dataweave would look like :</p><pre>%dw 2.0<br>output application/csv quoteHeader = true,quoteValues = true,separator = &quot;;&quot;<br>---<br>payload</pre><p>Output would look like :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5GSBqGZ_wAM5Ogrip3a2LQ.png" /></figure><p>Now in the above example we can see data with Header and Values information :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dLxd8VlJ5SUPYr1GFFm2oA.png" /></figure><p>Lets say we want to remove the header part and only have values in the output, in that case, we will use <strong>header </strong>properties in output directive and set its value to “f<strong>alse</strong>”</p><p><strong>Dataweave :</strong></p><pre>%dw 2.0<br>output application/csv quoteHeader = true,quoteValues = true,separator = &quot;;&quot;, header = false<br>---<br>payload</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*WuRWTeuTd6w1FzzK1zWjVw.png" /></figure><p>Till now we have explored thoroughly on how we can convert json file format to csv format while performing different operations.</p><h4>Now we will see how we can retrieve, access and concetenate csv related data</h4><p>We will use file that we generated in above usecase as input example for CSV</p><p><strong>Input</strong></p><pre>First Name,Last Name,Sex,EmployeeID,email_address,country<br>Mridul,Dixit,Female,123456,mridul.dixit@gmail.com,India<br>John,Downey,Male,12236,robert.downey@gmail.com,Germany</pre><p>In Dataweave, put this data at Input side and make sure to put correct file format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7Obm72Bi6USd63eNt2Sug.png" /></figure><h4><strong>Usecase 1: Retrieving all values in a column</strong></h4><p>Here we are trying to retrieve all the First Name (column) values from the given csv file.</p><pre>%dw 2.0<br>output application/java<br>---<br>payload.&quot;First Name&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qx6I1_B6idu58P_W5Asfdg.png" /></figure><p>We have used <strong>payload</strong>.<strong>“First Name” instead of (payload.First Name) here because there is a space in between First and Name. and it will throw error while accessing payload using payload.First Name,</strong></p><p>Eg: If input is FirstName , dw will be <strong>payload.FirstName</strong></p><p>If input is First Name, dw will be<strong> payload.”FirstName”</strong></p><h4><strong>Usecase 2: Access a particular record (row) of information</strong></h4><p>Lets say we want to access record number 2, which is John’s record.</p><p>Here [index] will help us in accessing the rows in csv file. Index starts from 0 to n.</p><p>So here in order to access record for Mridul, which is the first record, we will write -&gt; payload[0], however to access its next record it will be -&gt; payload[1]</p><pre>%dw 2.0<br>output application/java<br>---<br>payload[1]</pre><p><strong>Output :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2cIosozG-RfUsHGcNdLZtw.png" /></figure><h4><strong>Usecase 3 : Convert the payload as String</strong></h4><p>Lets say we want to log the payload as String, we can write following dataweave:</p><pre>%dw 2.0<br>output application/java<br>---<br>write(payload,&quot;application/csv&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBFSCfsQK6bEsqR2SJG-GQ.png" /></figure><h4>Usecase 4: Concetenate two csv files</h4><p>In this usecase, we are trying to concetenate two csv files by using “++” operator.</p><p>Input 1 (set as <strong>payload </strong>in Playground) :</p><pre>First Name,Last Name,Sex,EmployeeID,email_address,country<br>Mridul,Dixit,Female,123456,mridul.dixit@gmail.com,India<br>John,Downey,Male,12236,john.downey@gmail.com,Germany</pre><p>Input 2: (set as <strong>variable </strong>in Playground)</p><blockquote>Click here to see how to set mulitple inputs on dataweave playground</blockquote><pre>First Name,Last Name,Sex,EmployeeID,email_address,country<br>Ram,Dixit,Male,12856,ram.dixit@gmail.com,India<br>Robert,Downey,Male,12239,robert.downey@gmail.com,Germany</pre><p>Dataweave :</p><pre>%dw 2.0<br>output application/csv<br>---<br>payload ++ variable</pre><p>Output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*a2i8Iblo6-BeR_rtbL5vCw.png" /></figure><p>Yayy!! A lot of learnings today!! So now you have basic knowledge of how you can transform Json to CSV output with ease.</p><p>Go ahead and try out these usecases here : <a href="https://dataweave.mulesoft.com/learn/?projectMethod=GHRepo&amp;repo=mulesoft%2Fdocs-dataweave&amp;path=modules%2FROOT%2Fpages%2F_partials%2Fcookbook-dw%2Finsert-attribute"><strong><em>Dataweave Playground</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NEKx5XQy6rvGHN24" /><figcaption>Photo by <a href="https://unsplash.com/@fuuj?utm_source=medium&amp;utm_medium=referral">Fuu J</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Happy Learning !!! : )</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=861c8f37971c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MuleSoft DataWeave Part 6: Date and Time Operations]]></title>
            <link>https://medium.com/@mriduldixit19/date-and-time-operations-in-dataweave-c46da39ccb5?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c46da39ccb5</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 15:18:07 GMT</pubDate>
            <atom:updated>2024-04-20T09:57:22.926Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I’d like to walk you through various transformations that can be performed in DataWeave with regards to date and time.</p><p>It includes various DataWeave date time functions to perform date time conversions in different formats. We will solve different usecases to get accustomed to different date time related functions in dataweave.</p><p>After this blog, you will be able to perform different date time operations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h2lIluuewIaBMeD2EJvb4w.gif" /></figure><h3><strong>now() </strong>:</h3><p>This dataWeave function helps in returning the current date and time value</p><p>It returns a DateTime value for the current date and time.</p><h4><strong>Example : Fetch Current Date In dataweave</strong></h4><p>Dataweave expression:</p><pre>%dw 2.0<br>output application/java<br>---<br>now()</pre><p>Output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vkkYVpfBIfu9w3PXEG6_DQ.png" /></figure><p><strong>Here we are getting output as :</strong></p><p><strong>“ 2023–06–19T13:37:15.100174Z[GMT] ”</strong></p><p>As per different requirements, we might need to extract only the data format as <strong>2023–06–19 </strong>or only the time format <strong>as 13:37:15</strong> or convert the time in <strong>different timezone</strong></p><p>So we will go through different usecases to see how we can manipulate the given date and time format as per requirement.</p><p>Here we go!!!!</p><h3>Ready to implement?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*QB6gbgRI8djQvWa4df2Hkg.jpeg" /><figcaption><a href="https://dataweave.mulesoft.com/learn/"><strong>Click here to start coding</strong></a></figcaption></figure><h4>Usecase 1: <strong>Get Current Date In dataweave</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*dt1QzQgYw9kfo-C2q3oyBg.png" /></figure><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>now() as Date</pre><h4>Usecase 2: Get Current Time In dataweave</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*VlLtWFvHzROSUIhNCPW6dw.png" /></figure><pre>%dw 2.0<br>output application/java<br>---<br>now() as Time</pre><h4>Usecase 3: Get <strong>Year From Current Date in dataweave</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*0PKY55y1WEyiG_KxhfcQKg.png" /></figure><pre>%dw 2.output aplication/java<br>---<br>now().year</pre><h4>Usecase 4: Get <strong>day value from current Date in dateweave</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*HbUibJQuVnG6ubm2cnSTsw.png" /></figure><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>now().day</pre><h4>Usecase 5: Get month value from current Date in dateweave</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*QF-SqDxIZqppfGECyVStrA.png" /></figure><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>now().month</pre><h4>Usecase 6: <strong>Format Time In dataweave (HH:MM:SS)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*1bbaDJC-XsESZb2EYbtIcg.png" /></figure><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>now() as String{format : &quot;hh:mm:ss&quot;}</pre><h4>Usecase 7: <strong>Convert Current DateTime to specific string format(yyyy-MMM-dd)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*wNUyoRH_aUbENbHyJ2F7SQ.png" /></figure><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>now() as String {format: &quot;yyyy-MMM-dd&quot;}</pre><p>Here you will observe that in {format: “yyyy-<strong>MMM</strong>-dd”}</p><p><strong>“MMM” gives us month as “Jun”</strong></p><p><strong>“MM” gives us month as “06”.</strong></p><p>We will try this in next usecase.</p><h4>Usecase 8: Convert Current DateTime to specific string format(yyyy-MM-dd)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*xtmHDyEn-2aizOjHIjZIMQ.png" /></figure><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>now() as String {format: &quot;yyyy-MM-dd&quot;}</pre><h4>Usecase 9 : <strong>Convert Current Datetime to different Timezones</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*RsLAALx4qYrg3yNRdn20nw.png" /></figure><p>Here you will see how to convert data and time to different timezones</p><h4>Dataweave Expression:</h4><pre>%dw 2.0<br>output application/java<br>---<br>&quot;Date format&quot;:<br>{<br>&quot;Current date format&quot;: now(), <br>&quot;UTC format&quot; : now() &gt;&gt; &quot;UTC&quot;,<br>&quot;IST format&quot; : now() &gt;&gt; &quot;IST&quot;,<br>&quot;CET format&quot; : now() &gt;&gt; &quot;CET&quot;<br>}</pre><h3>Yayyy!!! You learned another DataWeave function!!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NqQpEV4wuR8dQHl7" /><figcaption>Photo by <a href="https://unsplash.com/@salimtetbirt?utm_source=medium&amp;utm_medium=referral">Tetbirt Salim</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Happy Learning!!!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c46da39ccb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dataweave : Flatten and DistinctBy— How to Find Unique Names from Input]]></title>
            <link>https://medium.com/@mriduldixit19/dataweave-flatten-and-distinctby-how-to-find-unique-names-from-input-2ab5969775ec?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ab5969775ec</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 08:13:50 GMT</pubDate>
            <atom:updated>2024-04-20T09:50:24.600Z</atom:updated>
            <content:encoded><![CDATA[<h3>DataWeave Part 5 : Flatten and DistinctBy— How to Find Unique Names from Input</h3><p>In this blog, I’d like to walk you through on implementation of “<strong>flatten</strong>” and “<strong>distinctBy</strong>” function in mule. By using these functions, we will solve the usecase of <strong>how to find Unique Names from the provided Input</strong>.</p><p>We will discuss on what, when and how to use this function, to make learning easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*79o6WlbOSaqDd50-V4Cuhw.png" /></figure><h3>What is Flatten function ?</h3><p>The <strong>flatten function</strong> is used to merge array of arrays into Single array</p><p>The <strong>flatten function</strong> iterates over an array and flatten subarrays of an array and collections of key-value pairs within DataWeave objects, arrays, and subarrays</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*PhLhINac39I0uswcdc_W_A.png" /></figure><h3>What is DistinctBy function ?</h3><p>The <strong>distinctBy </strong>function is useful when you need to remove duplicate items from an Array</p><p>The <strong>distinctBy </strong>function iterates over an array and finds unique values in an array.</p><h3>When to use Flatten and DistinctBy function ?</h3><p><strong>Flatten </strong>function will be used usually when we want to create a simple array from nested arrays</p><p><strong>DistinctBy </strong>function will be used to retrieve unique value from the given array</p><h3>How to use Flatten function?</h3><p>Syntax :</p><p>flatten&lt;T,Q&gt;(items:Array&lt;Array&lt;T&gt;|q&gt;):Array&lt;T|Q&gt;</p><h3>How to use DistinctBy function?</h3><p>Syntax :</p><p>distinctBy(Array&lt;T&gt;, ((T, Number) -&gt; Any)): Array&lt;T&gt;</p><h3>Time to implement the learnings. Lets play with dataweave!!!</h3><p><strong><em>Practice Dataweave here :- </em></strong><a href="https://developer.mulesoft.com/learn/dataweave/"><strong><em>Dataweave Playground</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MPpFGp1bYnb1THtfMUxX_w.gif" /></figure><p><strong>Usecase : We will find unique names from given Input with TWO DIFFERENT OUTPUT examples</strong></p><p>Solution will involve two steps to solve this :</p><p>Step 1: Using flatten function</p><p>Step 2: Using distinctBy function in the Step 1 result</p><p>You can use the following data to use as <strong>Input -</strong></p><pre>[<br>    [<br>        {<br>            &quot;name&quot;:&quot;Amit&quot;<br>        },<br>        {<br>            &quot;name&quot;:&quot;Johnny&quot;<br>        }<br>    ],<br>    [<br>        {<br>            &quot;name&quot;: &quot;Raj&quot;<br>        },<br>        {<br>            &quot;name&quot;: &quot;Alicia&quot;<br>        },<br>        {<br>            &quot;name&quot;: &quot;Jennifer&quot;<br>        },<br>        {<br>            &quot;name&quot;: &quot;Amit&quot;<br>        }<br>    ],<br>    [<br>         {<br>            &quot;name&quot;:&quot;Johnny&quot;<br>        },<br>         {<br>            &quot;name&quot;: &quot;Alicia&quot;<br>        }<br><br><br>    ]<br>]</pre><p>Put this input on left handside in dataweave playground :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WqtuBBlwMof3IIcxnhSbHg.png" /></figure><p><strong>Usecase a: Expected Output 1 will be as mentioned below:</strong></p><pre>[<br>  {<br>    &quot;name&quot;: &quot;Amit&quot;<br>  },<br>  {<br>    &quot;name&quot;: &quot;Johnny&quot;<br>  },<br>  {<br>    &quot;name&quot;: &quot;Raj&quot;<br>  },<br>  {<br>    &quot;name&quot;: &quot;Alicia&quot;<br>  },<br>  {<br>    &quot;name&quot;: &quot;Jennifer&quot;<br>  }<br>]</pre><p>Step 1: (It will flatten the arrays of array into single array by using <strong>flatten function</strong>)</p><p>This step will generate output like below-</p><pre>%dw 2.0<br>output application/json<br>---<br>flatten(payload)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvtNjidElBg_yYt3SDpcUg.png" /></figure><p>Step 2: This will find the unique value from given array by using <strong>distinctBy function along with step 1(flatten function) with the expected final output</strong></p><pre>%dw 2.0<br>output application/json<br>---<br>flatten(payload) distinctBy(item,index)-&gt; item</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWsSxXtyNkSmeDYBYC0Uyw.png" /></figure><p><strong>Usecase b: Expected Output 2 will be as mentioned below:</strong></p><pre>[<br>  &quot;Amit&quot;,<br>  &quot;Johnny&quot;,<br>  &quot;Raj&quot;,<br>  &quot;Alicia&quot;,<br>  &quot;Jennifer&quot;<br>]</pre><p>Step 1: Step 1: (It will flatten the arrays of array into single array by using <strong>flatten function and map function </strong>will transform every item in array and returns an Array)</p><p>This step will generate output like below-</p><pre>%dw 2.0<br>output application/json<br>---<br>flatten (payload map(item,index)-&gt; item.name)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w07IgSIqoVkduDOaA2m9dQ.png" /></figure><p>Step 2: This will find the unique value from given array by using <strong>distinctBy function along with step 1with the expected final output</strong></p><pre>%dw 2.0<br>output application/json<br>---<br>flatten (payload map(item,index)-&gt; item.name) distinctBy(item,index)-&gt; item</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vQHqcYIiIrSRHVZJ5TEAgQ.png" /></figure><p>Voila!! You have gained knowledge about another dataweave functions! Cheers!!! :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NYwhRIkglf54uL0w" /><figcaption>Photo by <a href="https://unsplash.com/@preciousjfm?utm_source=medium&amp;utm_medium=referral">Jewel Mitchell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ab5969775ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dataweave : Pluck function]]></title>
            <link>https://medium.com/@mriduldixit19/dataweave-pluck-function-b4b513537b97?source=rss-c656e8b8729b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4b513537b97</guid>
            <dc:creator><![CDATA[Mridul Dixit]]></dc:creator>
            <pubDate>Sat, 10 Jun 2023 11:45:45 GMT</pubDate>
            <atom:updated>2024-04-20T09:49:27.971Z</atom:updated>
            <content:encoded><![CDATA[<h3>MuleSoft DataWeave Part 4 : Pluck function — How to transform an Object into an Array</h3><p>In this blog, I’d like to walk you through on implementation of “pluck” function in mule. We will discuss on what, when and how to use this function, to make learning easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*79o6WlbOSaqDd50-V4Cuhw.png" /></figure><h3><strong>What is Pluck function ?</strong></h3><p>The <strong>pluck function</strong> is used to retrieve the key, value and index from an object and output the result to an array.</p><p>The <strong>pluck function </strong>is similar to other Object-like functions, for example, filterObject or mapObject. However, those two will return an Object, as opposed to pluck that returns an Array.</p><p>The <strong>pluck function</strong> iterates over an object and returns an array of keys, values, or indices from the object.</p><h3><strong>When to use Pluck function ?</strong></h3><p>When there is requirement to transform the Object into an Array</p><h3>How to use Pluck function?</h3><p><em>Syntax </em>: pluck((value: V, key: K, index: Number) -&gt; R): Array&lt;R&gt;)</p><p>To access the value: we use $</p><p>To access the key: we use $$.</p><p>To access the index : we use $$$.</p><p>“$” in general is used to access key in key/value pair and “$$” is used to access value in key/value pair</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s0W_Yjxp9UPgaK9FTYF_xg.gif" /></figure><h4>Time to implement the learnings. Lets play with dataweave!!!</h4><p>To quickly access dataweave playground, use the following link : <a href="https://dataweave.mulesoft.com/learn/">https://dataweave.mulesoft.com/learn/</a></p><p>You can use the following data to use as <strong>Input -</strong></p><pre>{<br>    &quot;name&quot;: &quot;Mridul&quot;,<br>    &quot;email&quot;: &quot;mridul@gmail.com&quot;<br>}</pre><p>Put this input on left handside in dataweave playground</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CSDb8uVV7ZRmlYPkDej-Iw.png" /></figure><p><strong><em>Usecase a. Retrieve all keys from input object :</em></strong></p><p><strong>Dataweave script:</strong></p><pre>%dw 2.0<br>output application/json<br>---<br>//One can use either of the logic to fetch all the keys from an input object<br>//payload pluck $$<br>payload pluck(value,key,index) -&gt; key</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUAzRRqNCHha4rx8mudYbg.png" /></figure><p><strong><em>Usecase b. Retrieve all values from input object :</em></strong></p><p><strong>Dataweave script:</strong></p><pre>%dw 2.0<br>output application/json<br>---<br>//One can use either of the logic to fetch all the keys from an input object<br>//payload pluck $<br>payload pluck(value,key,index) -&gt; value</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBnSqhcNt_nboMVcLrzAPw.png" /></figure><p><strong><em>Usecase c. Retrieve indices from input object :</em></strong></p><p><strong>Dataweave script:</strong></p><pre>%dw 2.0<br>output application/json<br>---<br>//One can use either of the logic to fetch all the keys from an input object<br>//payload pluck $$$<br>payload pluck(value,key,index) -&gt; index</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFDfYpUp6UCbRSVKEd79Tg.png" /></figure><p><strong><em>Usecase d. Retrieve all the keys,values and indices from input object :</em></strong></p><p><strong>Dataweave script:</strong></p><pre>%dw 2.0<br>output application/json<br>---<br>results:<br>{<br>    key: payload pluck $$,<br>    value: payload pluck $,<br>    indices: payload pluck $$$<br><br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJkZIqYAGK-3rkvP1QQufQ.png" /></figure><p>Voila!! You have learned another dataweave function!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qYbFSEur9H1PBk05" /><figcaption>Photo by <a href="https://unsplash.com/@preciousjfm?utm_source=medium&amp;utm_medium=referral">Jewel Mitchell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Follow for more… Happy Learning!!! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4b513537b97" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>