<?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 Default values for CSV lookups that don't match? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330275#M61217</link>
    <description>&lt;P&gt;I have a vehicle fleet lookup table like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;vehicle_id,vehicle_year,vehicle_type,vehicle_ends,vehicle_agency,vehicle_livery
1,1912,"A",2,"San Francisco Municipal Railway","San Francisco Municipal Railway"
228,1934,"",2,"Blackpool Tramways","Blackpool Tramways"
578,1896,"G",2,"Market Street Railway","Market Street Railway"
737,1952,"PCC",1,"Brussels, Belgium","Zurich, Switzerland"
1807,1928,"Milan",1,"Milan, Italy","Milan, Italy (1928)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;A &lt;CODE&gt;transforms.conf&lt;/CODE&gt; file like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Historic_fleet]
filename = Historic_fleet.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And a &lt;CODE&gt;props.conf&lt;/CODE&gt; file like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[NextBus]
category = Custom
disabled = false
LOOKUP-fleet = Historic_fleet vehicle_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This all works fine. However, there are occasionally other vehicles out that are busses. They have their own &lt;CODE&gt;vehicle_id&lt;/CODE&gt;s that are not in the lookup table. What I want is to have any &lt;CODE&gt;vehicle_id&lt;/CODE&gt; that is not found to map to a &lt;CODE&gt;vehicle_type=bus&lt;/CODE&gt;. I'd like to do this automatically so I don't have to do it for every query I write.&lt;/P&gt;

&lt;P&gt;I'm aware that a lookup table &lt;A href="https://answers.splunk.com/answers/443145/is-it-possible-to-add-a-default-value-for-a-lookup.html"&gt;can have a default value&lt;/A&gt;, but how do you specify that a default value of, say, &lt;CODE&gt;bus&lt;/CODE&gt;, is supposed to go into the &lt;CODE&gt;vehicle_type&lt;/CODE&gt; field?&lt;/P&gt;

&lt;P&gt;Can I do this with static tables? Or must I resort to using an &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/Configureexternallookups"&gt;external lookup Python script&lt;/A&gt;?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2017 00:32:30 GMT</pubDate>
    <dc:creator>plucas_splunk</dc:creator>
    <dc:date>2017-02-28T00:32:30Z</dc:date>
    <item>
      <title>Default values for CSV lookups that don't match?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330275#M61217</link>
      <description>&lt;P&gt;I have a vehicle fleet lookup table like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;vehicle_id,vehicle_year,vehicle_type,vehicle_ends,vehicle_agency,vehicle_livery
1,1912,"A",2,"San Francisco Municipal Railway","San Francisco Municipal Railway"
228,1934,"",2,"Blackpool Tramways","Blackpool Tramways"
578,1896,"G",2,"Market Street Railway","Market Street Railway"
737,1952,"PCC",1,"Brussels, Belgium","Zurich, Switzerland"
1807,1928,"Milan",1,"Milan, Italy","Milan, Italy (1928)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;A &lt;CODE&gt;transforms.conf&lt;/CODE&gt; file like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Historic_fleet]
filename = Historic_fleet.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And a &lt;CODE&gt;props.conf&lt;/CODE&gt; file like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[NextBus]
category = Custom
disabled = false
LOOKUP-fleet = Historic_fleet vehicle_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This all works fine. However, there are occasionally other vehicles out that are busses. They have their own &lt;CODE&gt;vehicle_id&lt;/CODE&gt;s that are not in the lookup table. What I want is to have any &lt;CODE&gt;vehicle_id&lt;/CODE&gt; that is not found to map to a &lt;CODE&gt;vehicle_type=bus&lt;/CODE&gt;. I'd like to do this automatically so I don't have to do it for every query I write.&lt;/P&gt;

&lt;P&gt;I'm aware that a lookup table &lt;A href="https://answers.splunk.com/answers/443145/is-it-possible-to-add-a-default-value-for-a-lookup.html"&gt;can have a default value&lt;/A&gt;, but how do you specify that a default value of, say, &lt;CODE&gt;bus&lt;/CODE&gt;, is supposed to go into the &lt;CODE&gt;vehicle_type&lt;/CODE&gt; field?&lt;/P&gt;

&lt;P&gt;Can I do this with static tables? Or must I resort to using an &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/Configureexternallookups"&gt;external lookup Python script&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 00:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330275#M61217</guid>
      <dc:creator>plucas_splunk</dc:creator>
      <dc:date>2017-02-28T00:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Default values for CSV lookups that don't match?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330276#M61218</link>
      <description>&lt;P&gt;The default value that you specify is placed into &lt;EM&gt;all&lt;/EM&gt; fields that are returned from the lookup, when there is no match. Default values work with static tables.&lt;/P&gt;

&lt;P&gt;I highly recommend setting a default value for lookup tables. It is an excellent solution to this sort of problem.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 00:42:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330276#M61218</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-02-28T00:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Default values for CSV lookups that don't match?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330277#M61219</link>
      <description>&lt;P&gt;There is nothing really automatic that doesn't overkill like @lguinn said, but you can do this manually:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup YourLookup | fillnull value="bus" vehicle_type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...  | eval vehicle_type="bus" | lookup YourLookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or even like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup YourLookup | eval vehicle_type=coalesce(vehicle_type, "bus")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can add this to a macro (e.g. &lt;CODE&gt;default_to_bus_vehicle_lookup&lt;/CODE&gt;) to make it centrally manageable and "automaticish".&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 18:29:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Default-values-for-CSV-lookups-that-don-t-match/m-p/330277#M61219</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-28T18:29:38Z</dc:date>
    </item>
  </channel>
</rss>

