<?xml version="1.0" encoding="windows-1252"?>
<node id="995574" title="Epoch time conversion in CSV" created="2012-09-25 11:30:35" updated="2012-09-25 11:30:35">
<type id="115">
perlquestion</type>
<author id="986045">
theneil</author>
<data>
<field name="doctext">
&lt;p&gt;Perl Gods,&lt;/p&gt;

&lt;p&gt;
I am generating a CSV file with the first 2 columns in the Epoch time format. I want to be able to run a script that converts and replaces these fields with a human readable date. How would I got about doing that - I'm just learning Perl so if you could explain it to me like I'm 5 that'd be great haha!
&lt;/p&gt;

&lt;p&gt;CSV:&lt;/p&gt;

&lt;code&gt;
1345752662, 1345752673, CLOSED, CRITICAL, Other fields etc
&lt;/code&gt;

&lt;p&gt;What I want:&lt;/p&gt;
&lt;code&gt;
Thu Aug 23 2012 15:11:02, Thu Aug 23 2012 15:11:13, CLOSED, CRITICAL, ETC
&lt;/code&gt;

I'm in the GMT-5 timezone and am not sure how to do that part either.

Thanks in advance!

&lt;p&gt;&lt;/p&gt;
&lt;p&gt;***************UPDATE:*****************
&lt;/p&gt;
&lt;p&gt;
Here is the solution I came up with thanks to you guys!

&lt;/p&gt;

&lt;code&gt;
#!/usr/bin/perl
use strict;
use Text::CSV;
use Tie::File;


my (@records, @removed);
tie @records, 'Tie::File', "test.csv";
@removed = splice(@records,0,2);
print join ("\n", @records);
untie @records;

my $file = 'test.csv';

my $csv = Text::CSV-&gt;new();

open (CSV, "&lt;", $file) or die $!;
open (MYFILE, '&gt;&gt;convertedDate.csv');

#Column Headers
#First 2 are in Epoch time
print MYFILE "Arrival, Modified Date, Severity, Status, TicketID, Message\n";
close (MYFILE);

while (&lt;CSV&gt;) 
{
    if ($csv-&gt;parse($_)) 
    {
      open (MYFILE, '&gt;&gt;convertedDate.csv');       
      my @columns = $csv-&gt;fields();
      #I know this next line isn't so elegant
      print MYFILE scalar(localtime(@columns[0])) . "," . scalar(localtime(@columns[1])) . ",\"" . @columns[2] . "\",\"" . @columns[3] . "\",\"" . @columns[4] . "\",\"" . @columns[5] . "\"";
      print MYFILE "\n";
      close (MYFILE);
    }
    else 
    {
      my $err = $csv-&gt;error_input;
      print "Failed to parse line: $err";
    }
}
close CSV;
&lt;/code&gt;
</field>
</data>
</node>
