simple CSV file import
[MojoFacets.git] / lib / MojoFacets / Data.pm
index 17cd670..5e59e7f 100644 (file)
@@ -16,6 +16,7 @@ use File::Path qw(mkpath);
 
 use MojoFacets::Import::File;
 use MojoFacets::Import::HTMLTable;
+use MojoFacets::Import::CSV;
 
 our $loaded;
 our $filters;
@@ -38,6 +39,9 @@ sub index {
                } elsif ( -d $file && $file =~ m/\.html$/ ) {
                        $file =~ s/$data_dir\/*//;
                        push @files, $file;
+               } elsif ( -f $file && $file =~ m/\.csv$/i ) {
+                       $file =~ s/$data_dir\/*//;
+                       push @files, $file;
                } else {
                        #warn "IGNORE: $file\n";
                }
@@ -178,7 +182,11 @@ sub _load_path {
 
        my $data;
        if ( -f $full_path ) {
-               $data = MojoFacets::Import::File->new( full_path => $full_path, path => $path )->data;
+               if ( $full_path =~ m/.csv/i ) {
+                       $data = MojoFacets::Import::CSV->new( full_path => $full_path )->data;
+               } else {
+                       $data = MojoFacets::Import::File->new( full_path => $full_path, path => $path )->data;
+               }
        } elsif ( -d $full_path && $full_path =~ m/.html/ ) {
                $data = MojoFacets::Import::HTMLTable->new( dir => $full_path )->data;
        } else {