SPUG: Newbie problem with Win32::OLE

Adam Monsen meonkeys at hotmail.com
Mon Dec 4 19:57:14 CST 2000


>In a nutshell, I am importing some text files from Unix, "converting" them
>to .csv files. I then open the .csv files in Excel and "save as" Excel 
>files
>(.xls). The whole thing works great, except that when I open the 
>"converted"
>.xls files, the data is no longer columnar (it is a single line separated 
>by
>commas.
I would recommend Text::CSV_XS for parsing/generating files in csv format. 
Try something like this (# added before each Perl line for clarity):

# #!/usr/bin/perl -w
# use strict;
# use Text::CSV_XS;
# my $csv = Text::CSV_XS->new( {always_quote=>1} );
# my @arr = qw(one two three);
# $csv->combine(@arr);
# $line = $csv->string;
# print $line,"\r\n";

Setting always_quote to 1 ensures that every field is quoted, which should 
allow all your Win32 apps to read the csv file.

Your problem may be later on when you save the file in Excel. I have messed 
around with this somewhat, and it appears that different Win32 apps use 
different formats for csv files. For instance, after I saved a file in cvs 
format in Excel 98, it could not be imported as csv by Access 2000.

On a side note, I would be interested if you have read and could point me to 
a spec for csv.

Did that help?

Adam Monsen
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list