On 24 June 2011 08:45, Wernher Eksteen <wekst...@gmail.com> wrote: > Hi, > > I've attached a text file containing the original and required format and > avoid the format > being lost by just pasting it in the email body. > > The original format is separated by a space, but need to replace the space > with a comma, > so it will become a comma delimited csv file which I will then import to MS > Excel. > > I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time" columns > since the dates > there in is in this format "Fri Jun 24 06:37" which also separated by space, > but the spaces in > those columns shouldn't be replaced by a comma. The date format in those > columns should > remain the same. > > Also, is it possible to convert this directly into a MS Excel document using > Perl?
Yes, you can achieve all your goals with perl. Have a look and Text::CSV_XS[1] or Text::CSV[2]. They will read the file correctly and write the file out for you with any separator you want. BTW, you want quotes around each field so as not to confuse you spreadsheet program. Writing the file into XLS format would require another module but I'll leave others to make that recommendation. Perhaps you could have a look at those, try and write something and when, or if, you get stuck, come back to the list showing the code you've got and get some pointers. Thanks, Dermot. 1) http://search.cpan.org/~hmbrand/Text-CSV_XS-0.82/CSV_XS.pm 2) http://search.cpan.org/~makamaka/Text-CSV-1.21/lib/Text/CSV.pm -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/