<?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 compress CSV file and email it on Unix platform? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197854#M39274</link>
    <description>&lt;P&gt;Sounds promising I'll try it out. Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jun 2014 13:51:25 GMT</pubDate>
    <dc:creator>amitkr0201</dc:creator>
    <dc:date>2014-06-13T13:51:25Z</dc:date>
    <item>
      <title>How to compress CSV file and email it on Unix platform?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197850#M39270</link>
      <description>&lt;P&gt;Is there an app/script/something else available which compresses a csv (preferably output of outputcsv command ) and emails it? Bonus point if its able to split it into multiple zips if size exceeds threshold.&lt;/P&gt;

&lt;P&gt;I am working on a set of data which, when extracted as CSV, sizes to approx 150 MB, which when compressed is &amp;gt;10 MB.&lt;/P&gt;

&lt;P&gt;The email provider I use allows max 8 MB attachments, so I need compression as well as splitting into multiple zip.&lt;/P&gt;

&lt;P&gt;EDIT: Platform = Unix&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 09:24:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197850#M39270</guid>
      <dc:creator>amitkr0201</dc:creator>
      <dc:date>2014-06-13T09:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to compress CSV file and email it on Unix platform?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197851#M39271</link>
      <description>&lt;P&gt;On what platform?  You don't specify Windows/Unix.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 11:23:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197851#M39271</guid>
      <dc:creator>grijhwani</dc:creator>
      <dc:date>2014-06-13T11:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to compress CSV file and email it on Unix platform?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197852#M39272</link>
      <description>&lt;P&gt;You can use a script which will break the zip file into pieces. If it more than the specified limit, send it in another mail. Don't use the default splunk script to send mail.&lt;/P&gt;

&lt;P&gt;_&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.1/alert/ConfiguringScriptedAlerts"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.1/alert/ConfiguringScriptedAlerts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Use the 8th argument to get the csv file then perform the zip and mailing.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
L&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 12:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197852#M39272</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-06-13T12:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to compress CSV file and email it on Unix platform?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197853#M39273</link>
      <description>&lt;P&gt;Linux provides &lt;CODE&gt;zip&lt;/CODE&gt;, &lt;CODE&gt;gzip&lt;/CODE&gt;, &lt;CODE&gt;bzip2&lt;/CODE&gt; for compression, and &lt;CODE&gt;split&lt;/CODE&gt; to (wait for it) split files into smaller files...  Then there are a multiplicity of ways of despatching the results as e-mails.&lt;/P&gt;

&lt;P&gt;Writing a shell script to compress the file, then chunk it into multiple fixed size attachments should be almost trivial.  If you are concerned about portability, then the better alternative is to split the source file at a given threshold and using zip specifically (for Windows compatibility) on the chunks individually.&lt;/P&gt;

&lt;P&gt;There you go.  Off the top of my head, and not debugged or checked, and dependent on installing Mutt as a mail client (because of its superior command line attachment management).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash
sMailTarget=you@your.domain
fSource=${SPLUNK_ARG_8}
[ -f ${fSource} ] || { echo "No file"; exit 1; }
# Comment the next line out of you want to send empty results
[ -s ${fSource} ] || { echo "Empty file"; exit 1; }
fPrefix="`echo ${fSource} | sed -e s'/.csv//'`-seg"

split -a 2 -l50000 ${fSource} ${fPrefix}
for ${fInter} in ${fPrefix}*; do
  mv ${fInter} ${fInter}.csv
  zip -9 ${fInter}.zip ${fInter}.csv
  mutt -s "${SPLUNK_ARG_4} result segment ${fInter}" -a ${fInter}.zip ${sMailTarget} &amp;lt;&amp;lt; EoM
File attached
EoM
done
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jun 2014 13:40:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197853#M39273</guid>
      <dc:creator>grijhwani</dc:creator>
      <dc:date>2014-06-13T13:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to compress CSV file and email it on Unix platform?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197854#M39274</link>
      <description>&lt;P&gt;Sounds promising I'll try it out. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 13:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compress-CSV-file-and-email-it-on-Unix-platform/m-p/197854#M39274</guid>
      <dc:creator>amitkr0201</dc:creator>
      <dc:date>2014-06-13T13:51:25Z</dc:date>
    </item>
  </channel>
</rss>

