At 9:45 AM +0200 6/24/11, Wernher Eksteen 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.


Since your columns are fixed-width, you can use the unpack function to unpack the lines into individual fields. You could also use a series of substr calls, but unpack would be less code.

See 'perldoc -f unpack' for details, and 'perldoc -f pack' for template elements describing your data columns.


Also, is it possible to convert this directly into a MS Excel document using Perl?

Not directly, but once you have the lines unpacked, you can use the Spreadsheet::WriteExcel module to create a spreadsheet and populate it with your data.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to