Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi I am new to perl programming: I am using the below code to convert excel file to CSV file and the format of date changes My source file.xls has dates as below: TDate VDate IDate 20/03/2014 00:08 26/03/2014 20/03/2014 08:07 Output of the .csv files looks as (changes the format when time exists in it). TDate VDate IDate 3-20-14 0:08 26/03/2014 3-20-14 8:07 Please help me with the code which does not change the datetime format of TDate and IDate Thanks. Below is the script I am using. Vijay perl script:
#!/usr/bin/perl -w # For each tab (worksheet) in a file (workbook), # spit out columns separated by ",", # and rows separated by c/r. use Spreadsheet::ParseExcel; use strict; my $file='output2.csv'; open STDOUT, ">", $file or die "$0: open: $!"; open STDERR, ">&STDOUT" or die "$0: dup: $!"; my $filename = shift || "/home/src/file.xls"; my $e = new Spreadsheet::ParseExcel; my $eBook = $e->Parse($filename); my $sheets = $eBook->{SheetCount}; my ($eSheet, $sheetName); foreach my $sheet (0 .. $sheets - 1) { $eSheet = $eBook->{Worksheet}[$sheet]; $sheetName = $eSheet->{Name}; #print "#Worksheet $sheet: $sheetName\n"; next unless (exists ($eSheet->{MaxRow}) and (exists ($eSheet->{Max +Col}))); foreach my $row ($eSheet->{MinRow} .. $eSheet->{MaxRow}) { foreach my $column ($eSheet->{MinCol} .. $eSheet->{MaxCol}) { if (defined $eSheet->{Cells}[$row][$column]) { print $eSheet->{Cells}[$row][$column]->Value . ","; } else { print ","; } } print "\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Excel to CSV datetime conversion- format changes
by vsmeruga (Acolyte) on Apr 24, 2014 at 15:10 UTC | |
|
Re: Excel to CSV datetime conversion- format changes
by vsmeruga (Acolyte) on Apr 24, 2014 at 15:18 UTC | |
by runrig (Abbot) on Apr 24, 2014 at 16:35 UTC | |
by Anonymous Monk on Apr 24, 2014 at 16:55 UTC | |
by runrig (Abbot) on Apr 24, 2014 at 17:04 UTC | |
by vsmeruga (Acolyte) on Apr 25, 2014 at 09:19 UTC | |
|