Perl module Spreadsheet::Read::Simple
for simple parsing of spreadsheets
# Include module
use Spreadsheet::Read::Simple;
# Read spreadsheet
my $book = ReadDataSimple($file);
This module combines the capabilities of the modules Spreadsheet::Read
and DataExtract::FixedWidth
in order to parse both, conventional
spreadsheets and text files with data in fixed width columns.
The latter is being achieved by converting the text file with fixed
width columns to a temporary CSV spreadsheet and parsing this file using
the method ReadData
provided by Spreadsheet::Read
.
The following symbols are exported.
&ReadDataSimple
-
ReadDataSimple( source [, option => value [, ... ]])`
The subroutine
ReadDataSimple
is a wrapper for the subroutineReadData
. It receives a mandatory argument source which can be the name of file or a file handle. If it is a file, several checks are being performed in order to identify text files with fixed-width columns. If these checks are positive the text file is converted to an temporary CSV file and afterwards parsed using the ordinary subroutineReadData
. The subroutineReadDataSimple
may receive additional arguments in key-value-syntax. Refer to the documentation ofSpreadsheet::Read
for details. The following options are recognized:-
sep => char
The option sep sets the separation character needed for parsing CSV files. If omitted, the separation character is auto-detected using the module
Text::CSV::Separator
. -
parser => fmt
The option parser sets the spreadsheet format. If omitted, the routine will try to detect it automatically be its MIME type. Known settings are:
csv
,ods
,xls
,xlsx
.
-
- DataExtract::FixedWidth
- File::MimeInfo
- File::Temp
- Scalar::Util
- Spreadsheet::Read
- Spreadsheet::Write
- Text::CSV::Separator
- Text::Trim
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.