On 9/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> There is a report that is generated from a script as a plain text file. I 
> need to take this output file as input for my script and join them and create 
> a CSV file and mail to me daily. How can I create CSV file with out using 
> modules.

As long as none of the fields contain ',', '"', or "\n", the
conversion is pretty simple: insert a comma after each field but the
last on each line.  If there _are_ any special characters in a field,
double any '"' that appear there, and enclose the entire field in
quotes.  So the field:

  Jonathan "Dataweaver" Lang, programmer

would become:

  "Jonathan ""Dataweaver"" Lang, programmer"

> Taking a sample report ....
>
> Hostname          IP address              Physical Address.
> inxp1233           XXX.XXX.XXX.XXX     Mac-address
> inxp1432           XXX.XXX.XXX.XXX     Mac-address
> inxp1232           XXX.XXX.XXX.XXX     Mac-address
>
> If I am joining this with a ',' and saving renaming the text file to CSV will 
> help or is there any other way to do it?Also I need to bold the header in my 
> CSV.

The matter of the headers isn't handled in the body of the text.  But
if you're assigning a mime type to it, you can assign a parameter to
the type that indicates that the first line defines column headers.

The real trick is going the other way - that is, parsing a CSV file.

-- 
Jonathan "Dataweaver" Lang

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to