<?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 SPL challenge ! Fusionning a multi |eval expression into one line ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748023#M118869</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm onboarding some new data and I'm working on the fields extraction.&lt;BR /&gt;Data is some proper JSON related to emails.&lt;/P&gt;&lt;P&gt;I'm having some hard time with the "attachments" field which I'm trying to make CIM compliant.&lt;/P&gt;&lt;P&gt;This attachment field is multivalue (it's a JSON array) and contains :&lt;/P&gt;&lt;P&gt;- The string "attachments" in the 0 position (the first position)&lt;BR /&gt;- The file name in every impair position (1, 3 , 5, etc.)&lt;BR /&gt;- The file hash in every pair position&lt;/P&gt;&lt;P&gt;So far, I've done it in SPL but I cant find a way to do that in a props.conf (because in props.conf, you can't do a multiline |eval : Every eval is treated in a parrallel way) or in a transforms.conf.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I've done in SPL :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval attachments = mvappend("attachments", "doc1.pdf", "abc123", "doc2.pdf", "def456", "doc3.bla", "ghx789")


``` To get rid of the string "attachments" ```
| eval attachments = mvindex(attachments, 1, mvcount(attachments)-1)

```To create an index```
| eval index_attachments=mvrange(0,mvcount(attachments),1)

```To write down in file_type is the value is file_name or file_hash :```
| eval modulo = mvmap(index_attachments, 'index_attachments'%2)
| eval file_type = mvmap(modulo, if(modulo=0,"file_name", "file_hash"))

``` To zip all that with a  "::::SPLIT::::" ```
| eval file_pair = mvzip('file_type', attachments, "::::SPLIT::::")

``` To then create file_name and file_hash```
| eval file_name = mvmap(file_pair, if(match(file_pair, "file_name::::SPLIT::::.*"), 'file_pair', null() ))
| eval file_hash = mvmap(file_pair, if(match(file_pair, "file_hash::::SPLIT::::.*"), 'file_pair', null() ))
| eval file_name = mvmap(file_name, replace(file_name, "file_name::::SPLIT::::", ""))
| eval file_hash = mvmap(file_hash, replace(file_hash, "file_hash::::SPLIT::::", ""))

| fields - attachments file_pair file_type index_attachments modulo attachments&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd be very glad to find a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your kind help !&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jun 2025 13:10:45 GMT</pubDate>
    <dc:creator>gargantua</dc:creator>
    <dc:date>2025-06-16T13:10:45Z</dc:date>
    <item>
      <title>SPL challenge ! Fusionning a multi |eval expression into one line ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748023#M118869</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm onboarding some new data and I'm working on the fields extraction.&lt;BR /&gt;Data is some proper JSON related to emails.&lt;/P&gt;&lt;P&gt;I'm having some hard time with the "attachments" field which I'm trying to make CIM compliant.&lt;/P&gt;&lt;P&gt;This attachment field is multivalue (it's a JSON array) and contains :&lt;/P&gt;&lt;P&gt;- The string "attachments" in the 0 position (the first position)&lt;BR /&gt;- The file name in every impair position (1, 3 , 5, etc.)&lt;BR /&gt;- The file hash in every pair position&lt;/P&gt;&lt;P&gt;So far, I've done it in SPL but I cant find a way to do that in a props.conf (because in props.conf, you can't do a multiline |eval : Every eval is treated in a parrallel way) or in a transforms.conf.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I've done in SPL :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval attachments = mvappend("attachments", "doc1.pdf", "abc123", "doc2.pdf", "def456", "doc3.bla", "ghx789")


``` To get rid of the string "attachments" ```
| eval attachments = mvindex(attachments, 1, mvcount(attachments)-1)

```To create an index```
| eval index_attachments=mvrange(0,mvcount(attachments),1)

```To write down in file_type is the value is file_name or file_hash :```
| eval modulo = mvmap(index_attachments, 'index_attachments'%2)
| eval file_type = mvmap(modulo, if(modulo=0,"file_name", "file_hash"))

``` To zip all that with a  "::::SPLIT::::" ```
| eval file_pair = mvzip('file_type', attachments, "::::SPLIT::::")

``` To then create file_name and file_hash```
| eval file_name = mvmap(file_pair, if(match(file_pair, "file_name::::SPLIT::::.*"), 'file_pair', null() ))
| eval file_hash = mvmap(file_pair, if(match(file_pair, "file_hash::::SPLIT::::.*"), 'file_pair', null() ))
| eval file_name = mvmap(file_name, replace(file_name, "file_name::::SPLIT::::", ""))
| eval file_hash = mvmap(file_hash, replace(file_hash, "file_hash::::SPLIT::::", ""))

| fields - attachments file_pair file_type index_attachments modulo attachments&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd be very glad to find a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your kind help !&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2025 13:10:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748023#M118869</guid>
      <dc:creator>gargantua</dc:creator>
      <dc:date>2025-06-16T13:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: SPL challenge ! Fusionning a multi |eval expression into one line ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748044#M118872</link>
      <description>&lt;P&gt;Your data is ugly. But almost all email data is ugly.&lt;/P&gt;&lt;P&gt;So my solution will be even uglier (and horribly inefficient).&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval attachments = mvappend("attachments", "doc1.pdf", "abc123", "doc2.pdf", "def456", "doc3.bla", "ghx789")&lt;BR /&gt;| eval file_name=mvmap(split(replace(mvjoin(mvindex(attachments,1,mvcount(attachments)),"|"),"([^|]+)\|([^|]+)\|","\\1|\\2||"),"||"),replace(attachments,"\|.*",""))&lt;/PRE&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval attachments = mvappend("attachments", "doc1.pdf", "abc123", "doc2.pdf", "def456", "doc3.bla", "ghx789")&lt;BR /&gt;| eval file_hash=mvmap(split(replace(mvjoin(mvindex(attachments,1,mvcount(attachments)),"|"),"([^|]+)\|([^|]+)\|","\\1|\\2||"),"||"),replace(attachments,".*\|",""))&lt;/PRE&gt;&lt;P&gt;You might want to adjust the separators from | and ||.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2025 21:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748044#M118872</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-06-16T21:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: SPL challenge ! Fusionning a multi |eval expression into one line ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748087#M118882</link>
      <description>&lt;P&gt;Thanks a million.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 08:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SPL-challenge-Fusionning-a-multi-eval-expression-into-one-line/m-p/748087#M118882</guid>
      <dc:creator>gargantua</dc:creator>
      <dc:date>2025-06-17T08:10:23Z</dc:date>
    </item>
  </channel>
</rss>

