[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Parsing Excel export files (fwd)



According to James Sentman:
> Not long ago someone posted a request to the evangelist asking for help in
> renaming a bunch of files based on what he had entered in an excel
> spreadsheet. I thought this would be a perfect problem to solve with
> MacPerl. He's exporting to a comma delimited file and I've set the record
> separator to a comma, but it isn't able to load the records into an array.
> I am further hindered by the fact that I cannot get Excel to run on my 8600
> here at work so I can't actually test the thing how I would like to.
> 
> Does anyone have any wisdom about parseing exported files from Excel?

How about:

#!perl
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
	@theList = ();
	open( THEFILE, "excel.dat" ) || die $!;
	@theList = <THEFILE>;
	close( THEFILE );

	foreach( @theList ){
		@theLine = split( /\s*,\s*/ );
		foreach( @theLine ){
			print "$_ : ";
			}

		print "\n";
		}

	exit( 0 );
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#

This will (or should) read in the file and split it into
it's component parts.  Since I do not know if Excel places
white space around the comma - I've include something to
take that into account.

Once you get this far - you should be able to use the data
to determine the filename etc...

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch