<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to check if a string is present in a dictionary and print the remaining data in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656624#M54089</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; the data comes from Splunk index and it is csv file&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2023 07:38:00 GMT</pubDate>
    <dc:creator>anooshac</dc:creator>
    <dc:date>2023-09-05T07:38:00Z</dc:date>
    <item>
      <title>How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656602#M54081</link>
      <description>&lt;P&gt;I have a CSV file which has a some columns. There is one column named GROUP and the data in that column are in the format {'a':1,'b':2}, there can be any number of strings. There is another column VALUE and the data are in the format {'a','b'}.&lt;/P&gt;&lt;P&gt;I want to check if the strings in VALUE column are present in GROUP column and create a separate column named DATA with the strings not present. I am not sure how to achieve it in Splunk using commands. Can anyone have any suggestions?&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Group &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Data&lt;/P&gt;&lt;P&gt;{'a':'1','b':'2'}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {'a','b'}&lt;/P&gt;&lt;P&gt;{'a':1,'b':'2'}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {'a'}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {'b'}&lt;/P&gt;&lt;P&gt;{'a':1,'b':'2','c':'3'}&amp;nbsp;&amp;nbsp;&amp;nbsp; {'a'}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {'b','c'}&lt;/P&gt;&lt;P&gt;There are many columns like these and strings present in GROUP column can be more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 05:15:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656602#M54081</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2023-09-05T05:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656603#M54082</link>
      <description>&lt;P&gt;You can do it like this runnable example with your data - using from the rex statement&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Group                     Value              Data
{'a':'1','b':'2'}            {'a','b'}
{'a':1,'b':'2'}              {'a'}                {'b'}
{'a':1,'b':'2','c':'3'}    {'a'}                {'b','c'}"
| multikv forceheader=1
| table Group Value Data
``` This is your Splunk SPL ```
| rex field=Group max_match=0 "'(?&amp;lt;g&amp;gt;\w)':"
| rex field=Value max_match=0 "'(?&amp;lt;v&amp;gt;\w)'"
| eval Calculated_Data=mvmap(g, if(g!=v, g, null()))
| eval Calculated_Data="{'".mvjoin(Calculated_Data, "','")."'}"
| fields - g v&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;So, if you have a CSV file with Group and Value in it, then&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup your_csv.csv
| rex field=Group max_match=0 "'(?&amp;lt;g&amp;gt;\w)':"
| rex field=Value max_match=0 "'(?&amp;lt;v&amp;gt;\w)'"
| eval Data=mvmap(g, if(g!=v, g, null()))
| eval Data="{'".mvjoin(Data, "','")."'}"
| fields - g v&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 05:38:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656603#M54082</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-05T05:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656605#M54083</link>
      <description>&lt;P&gt;Should the csv file uploaded as lookup file? Can we avoid that?&lt;/P&gt;&lt;P&gt;Also the strings can contain _ as well as they can be capital letters and small letters.. how can i do this? This [A-Za-z_] regular expression is fine?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 05:56:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656605#M54083</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2023-09-05T05:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656607#M54084</link>
      <description>&lt;P&gt;Just change the regex in the 2 rex statements&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Group;Value;Data
{'Ala_ABC':'1','Bob_XX_':'2'};{'Ala_ABC','Bob_XX_'};
{'Ala_ABC':1,'Bob_XX_':'2'};{'Ala_ABC'};{'Bob_XX_'}
{'Ala_ABC':1,'Bob_XX_':'2','_c_is_for_Charlie':'3'};{'Ala_ABC'};{'Bob_XX_','_c_is_for_Charlie'}"
| multikv forceheader=1
| table Group Value Data
``` This is your Splunk SPL ```
| rex field=Group max_match=0 "'(?&amp;lt;g&amp;gt;[A-Za-z_]+)':'"
| rex field=Value max_match=0 "'(?&amp;lt;v&amp;gt;[A-Za-z_]+)'"
| eval Calculated_Data=mvmap(g, if(g!=v, g, null()))
| eval Calculated_Data="{'".mvjoin(Calculated_Data, "','")."'}"
| fields - g v&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Sep 2023 06:14:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656607#M54084</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-05T06:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656608#M54085</link>
      <description>&lt;P&gt;Where is your data coming from? Data has to be either&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) In a Splunk index&lt;BR /&gt;b) In a lookup in Splunk&lt;BR /&gt;c) Part of your search, as in my | makeresults example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 06:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656608#M54085</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-05T06:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656610#M54087</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/30057"&gt;@anooshac&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;these seems to be data in json format.&lt;/P&gt;&lt;P&gt;If they aren't&amp;nbsp; in a lookup, you could parse them and store in an index using the INDEXED_EXTRACTIONS=json option of props.conf (&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.1/Admin/Propsconf" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.1/Admin/Propsconf&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;In this way you extract all the fields and you can use the values for your matches.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 06:23:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656610#M54087</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-05T06:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656612#M54088</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; , the method you mentioned is working fine..&lt;/P&gt;&lt;P&gt;Sorry for not mentioning before, the column VALUE can have data like {'a','b'} or a. In such cases how can i change the regex?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 06:24:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656612#M54088</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2023-09-05T06:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656624#M54089</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; the data comes from Splunk index and it is csv file&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 07:38:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656624#M54089</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2023-09-05T07:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a string is present in a dictionary and print the remaining data</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656732#M54095</link>
      <description>&lt;P&gt;Just add any additional character groupings into the allowed character ranges, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=Group max_match=0 "'(?&amp;lt;g&amp;gt;[A-Za-z_\.]+)':'"
| rex field=Value max_match=0 "'(?&amp;lt;v&amp;gt;[A-Za-z_\.]+)'"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Sep 2023 21:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-check-if-a-string-is-present-in-a-dictionary-and-print/m-p/656732#M54095</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-05T21:16:21Z</dc:date>
    </item>
  </channel>
</rss>

