Skip to content
Browse files

Merge branch 'master' of git://github.com/dhoss/perl-survey-2009

  • Loading branch information...
2 parents 67ce793 + 8940820 commit 596f4b9eb48c32153caf71186a3666908bc53ab6 Kieren Diment committed
Showing with 21 additions and 2 deletions.
  1. +19 −0 Survey-Perl/script/survey_csv_matrix.pl
  2. +2 −2 Survey-Perl/survey_perl.conf
View
19 Survey-Perl/script/survey_csv_matrix.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Text::CSV_XS;
+use Survey::Perl::Answers::Schema;
+use Config::JFDI;
+use Data::Dumper;
+my $conf = Config::JFDI->new( name => "Survey::Perl" );
+my $config = $conf->get;
+my $schema =
+ Survey::Perl::Answers::Schema->connect( @{ $config->{'Model::Answers'}->{connect_info} }, );
+my $csv = Text::CSV_XS->new({binary => 1});
+my $answer_rs = $schema->resultset('Survey')->all;
+
+open my $fh, ">", $ARGV[0] or die "can't open file for writing: $!\n";
+while ( my $answer = $answer_rs->next ) {
+ $csv->print($fh, { $_ => $answer->$_ } ) for $answer->columns or die "couldn't write row: " . $csv->error_diag;
+}
+close $fh;
View
4 Survey-Perl/survey_perl.conf
@@ -12,12 +12,12 @@ default_view Web
connect_info user
connect_info passwd
</Model>
- <Model Answers>
+ <Model::Answers>
schema_class Survey::Perl::Answers::Schema
connect_info dbi:SQLite:__path_to(db/answers.db)__
connect_info ""
connect_info ""
- </Model>
+ </Model::Answers>
<View JSON>
expose_stash autocomplete
</View>

0 comments on commit 596f4b9

Please sign in to comment.
Something went wrong with that request. Please try again.