NAME
Data::File::Map - Read data file definitions stored as XML
SYNOPSIS
use Data::File::Map;
# load data file definition
$map = Data::File::Map->new_from_file( 'path/to/map.xml' );
# read records from a data file using the map
open FILE, 'data.txt' or die "Could not open file.";
while( <FILE> ) {
$record = $map->read( $_ );
}
close FILE;
DESCRIPTION
Data::File::Map will allow you to read in a data file definition stored as XML. The map can then be used to parse records in a data file. Handles delimited and formatted text data.
ATTRIBUTES
- format
-
The format of the data file. Can be either
csv
for delimited files or 'text' for formatted ascii files. - separator
-
Used to separate variables in a csv file. This is a regular expression.
METHODS
- fields
-
Returns a list of ArrayRefs containing information about the fields in the definition. The format off the ArrayRefs is
[$field_name, $position, $width]
. Position and width will only be defined intext
files. - field_names
-
Returns a list of field names in the order defined in the definition file.
- new
-
Create a new Data::File::Map instance.
- new_from_file $path
-
Create a new Data::File::Map instance and load definition from a file.
- new_from_string $string
-
Create a new Data::File::Map instance and load definition from a string.
- parse_file $path
-
Load definition from a file.
- parse_string $string
-
Load definition from a string.
- read $line
-
Takes a line from a data file and uses the definition to extaract the variables. Returns a HashRef with field names as keys.
- read_file $path
-
Calls
read
on each line in the given file and returns an array of records.
AUTHORS
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
COPYRIGHT
Copyright (c) 2013 Jeffrey Ray Hallock.
LICENSE
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)