1 package CXGN
::BrAPI
::FileResponse
;
5 use Spreadsheet
::WriteExcel
;
7 has
'absolute_file_path' => (
13 has
'absolute_file_uri' => (
26 isa
=> 'ArrayRef[ArrayRef]',
33 my $format = $self->format;
34 if ($format ne 'tsv' && $format ne 'csv' && $format ne 'xls'){
35 die "format must be tsv, csv, or xls\n";
41 my $format = $self->format;
42 if ($format eq 'csv'){
45 if ($format eq 'tsv'){
48 if ($format eq 'xls'){
55 my $data_array = $self->data;
56 my $file_path = $self->absolute_file_path;
58 my $num_col = scalar(@
{$data_array->[0]});
59 open(my $fh, ">", $file_path);
60 print STDERR
$file_path."\n";
61 foreach my $cols (@
$data_array){
63 for(my $i=0; $i<$num_col; $i++) {
65 print $fh "\"$cols->[$i]\"";
69 if ($step < $num_col) {
77 my @datafiles = ($self->absolute_file_uri);
83 my $data_array = $self->data;
84 my $file_path = $self->absolute_file_path;
86 my $num_col = scalar(@
{$data_array->[0]});
87 open(my $fh, ">", $file_path);
88 print STDERR
$file_path."\n";
89 foreach my $cols (@
$data_array){
91 for(my $i=0; $i<$num_col; $i++) {
93 print $fh $cols->[$i];
97 if ($step < $num_col) {
105 my @datafiles = ($self->absolute_file_uri);
111 my $data_array = $self->data;
112 my $file_path = $self->absolute_file_path;
114 my $ss = Spreadsheet
::WriteExcel
->new($file_path);
115 my $ws = $ss->add_worksheet();
117 for (my $line=0; $line< scalar(@
$data_array); $line++) {
118 $ws->write_row($line, 0, $data_array->[$line]);
121 my @datafiles = ($self->absolute_file_uri);