We help IT Professionals succeed at work.

New podcast episode! Our very own Community Manager, Rob Jurd, gives his insight on the value of an online community. Listen Now!

x

data manipulation, change date format in perl

Begunix
Begunix asked
on
279 Views
Last Modified: 2012-05-05
Sample data.csv

"09/05/2001","101","01","abc"
"09/05/2001","107","02","def"
"09/05/2001","109","03","ghi"
"09/06/2001","111","01","jkl"
"09/06/2001","113","02","mno"
"09/06/2001","115","03","pqr

perl script to get the outputdata.csv to be
05-Sep-2001-101,abc
05-Sep-2001-107,def
05-Sep-2001-109,ghi
06-Sep-2001-111,jkl
06-Sep-2001-113,mno
06-Sep-2001-115,pqr

Thanks
Begunix
Comment
Watch Question

Top Expert 2009

Commented:
my @mon=qw(nul Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
while(<>) {
      my @f=split(/[",\/]+/);
      print join("-", $f[2],$mon[$f[1]],@f[3,4]),",$f[6]\n";
}

Author

Commented:
Thanks for the reply. I apologize for the confusion.
The sample data in test.csv
09/07/2001,101,1700,abc
09/08/2001,103,1800,cde
10/04/2001,105,0100,fgh
11/03/2001,107,1700,hij
11/12/2001,301,1900,klm
12/05/2001,501,1700,nop
01/01/2002,601,0500,qrs

output file (output.csv) should be as given below.
07-Sep-2001-17-00,abc,101
08-Sep-2001-18-00,cde,103
04-Oct-2001-01-00,fgh.105
03-Nov-2001-17-00.hij,107
12-Nov-2001-19-00,klm,301
05-Dec-2001-17-00,nop,501
01-Jan-2002-05-00,qrs,601

Thanks
Begunix
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.