<?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 parse date and time in different columns during CSV import? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206692#M40797</link>
    <description>&lt;P&gt;Findings after further investigation.&lt;/P&gt;

&lt;P&gt;Browsing further into the preview the timestamp gets recognized and importing the 2014 CSV works, except for first ~100 events. But CSV from year 2013 has the time in hh.mm (dot instead of colon) and I cannot import it.&lt;/P&gt;

&lt;P&gt;Curiously, if I preview the extraction of date or time only, the TIME_FORMAT (%d/%m/%Y or %H.%M) is comfirmed to be correct. Concatenation doesn't seem to work (reliably). Swapping date and time neither.&lt;/P&gt;

&lt;P&gt;I would prefer not to edit the source CSV with +700k lines.&lt;/P&gt;

&lt;P&gt;Splunk version 6.2.2.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2015 11:07:34 GMT</pubDate>
    <dc:creator>felipetesta</dc:creator>
    <dc:date>2015-09-08T11:07:34Z</dc:date>
    <item>
      <title>How to parse date and time in different columns during CSV import?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206691#M40796</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;My raw CSV data looks like this (it's open data, no anonymization needed):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Anno;Reg;Articolo;Classe;Dat Infr;Loc1;Numciv1;Bisinternolettera;Loc2;Ora Infr;Sanzione accessoria;Tipoinfr;Numero Verbali;Sanzioni
2014;Legge 285/92;158;Autovettura;01/07/2014;SEBASTOPOLI/(CORSO);238;B;(Altri);0:00;(Mancante);Sosta;1;1
2014;Legge 285/92;142;Autovettura;01/07/2014;UNITA' D'ITALIA/(CORSO);96;AFR.EST;(Altri);0:01;(Mancante);Limiti di Velocita';1;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Date is in column 5 "Dat Infr" and time in column 9 "Ora Infr". I tried most combinations with/out quotes, comma, semicolon, SHOULD_LINEMERGE true/false, but nothing has worked and the correct timestamp doesn't come up. On the other hand, I can get Splunk to recognize the date field if I leave it alone in TIMESTAMP_FIELDS and TIME_FORMAT. The proposed props.conf is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ csv ]
TIME_FORMAT=%d/%m/%Y,%H:%M
TZ=Europe/Rome
MAX_TIMESTAMP_LOOKAHEAD=500
TIMESTAMP_FIELDS=Dat Infr,Ora Infr
SHOULD_LINEMERGE=false
INDEXED_EXTRACTIONS=csv
NO_BINARY_CHECK=true
KV_MODE=none
disabled=false
pulldown_type=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I missing? Even the official docs have a similar unanswered question at &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/Data/ConfigurePositionalTimestampExtraction" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/Data/ConfigurePositionalTimestampExtraction&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:10:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206691#M40796</guid>
      <dc:creator>felipetesta</dc:creator>
      <dc:date>2020-09-29T07:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse date and time in different columns during CSV import?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206692#M40797</link>
      <description>&lt;P&gt;Findings after further investigation.&lt;/P&gt;

&lt;P&gt;Browsing further into the preview the timestamp gets recognized and importing the 2014 CSV works, except for first ~100 events. But CSV from year 2013 has the time in hh.mm (dot instead of colon) and I cannot import it.&lt;/P&gt;

&lt;P&gt;Curiously, if I preview the extraction of date or time only, the TIME_FORMAT (%d/%m/%Y or %H.%M) is comfirmed to be correct. Concatenation doesn't seem to work (reliably). Swapping date and time neither.&lt;/P&gt;

&lt;P&gt;I would prefer not to edit the source CSV with +700k lines.&lt;/P&gt;

&lt;P&gt;Splunk version 6.2.2.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 11:07:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206692#M40797</guid>
      <dc:creator>felipetesta</dc:creator>
      <dc:date>2015-09-08T11:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse date and time in different columns during CSV import?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206693#M40798</link>
      <description>&lt;P&gt;Answering my own question after half-a-day of research and trial&amp;amp;error.&lt;/P&gt;

&lt;P&gt;I checked strptime() man page and found a "wildcard"  field descriptor: %n, "Arbitraty whitespace". So, replacing the "comma" with "%n" into&lt;/P&gt;

&lt;P&gt;TIME_FORMAT=%d/%m/%Y%n%H:%M&lt;/P&gt;

&lt;P&gt;did the trick. Mind that CSV field names are case sensitive. Double quotes are not necessary if the CSV field name contains whitespace.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 13:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-date-and-time-in-different-columns-during-CSV/m-p/206693#M40798</guid>
      <dc:creator>felipetesta</dc:creator>
      <dc:date>2015-09-08T13:50:46Z</dc:date>
    </item>
  </channel>
</rss>

