new input file
[openface-maja] / p.pl
diff --git a/p.pl b/p.pl
index caed5e9..cdd2990 100755 (executable)
--- a/p.pl
+++ b/p.pl
@@ -6,11 +6,13 @@ use Data::Dump qw(dump);
 use Text::Unaccent;
 use POSIX qw(strftime);
 
-my $filename = 'Intervali_Openface_novi_rad_Boris_export.txt';
+#my $filename = 'Intervali_Openface_novi_rad_Boris_export.txt';
+my $filename = 'originals_2023-07-09/Intervali_Openface_novi_rad_Boris_export.txt';
 
 my $debug = $ENV{DEBUG} || 0;
 
-my $today = strftime("%Y-%m-%dT%H:%M:%S", localtime(time()));
+# better time format for scp (don't have :)
+my $today = strftime("%Y-%m-%d_%H%M%S", localtime(time()));
 warn "# today $today";
 
 open(my $err_fh, '>', "out.$today.log");
@@ -71,7 +73,12 @@ sub glob_id {
 }
 
 open(my $skipped_input, '>',"out.$today.skip");
-open(my $out_fh, '>', "out.$today");
+open(my $out_fh, '>', "out.$today.csv");
+sub out_csv {
+       my @a = @_;
+       print $out_fh join(",", map { m/\s/ ? qq{"$_"} : $_ } @a),"\n";
+}
+
 my @out_header;
 
 while(<$fh>) {
@@ -155,7 +162,7 @@ while(<$fh>) {
                                push @out_header, map { $h2[$_] }
                                        ( $h2nr->{'AU01_c'} .. $h2nr->{'AU45_c'} );
                                warn "# out_header ",dump( \@out_header );
-                               print $out_fh join("\t", @out_header),"\n";
+                               out_csv @out_header;
                        }
                        next;
                }
@@ -206,7 +213,7 @@ while(<$fh>) {
                        push @add_cols, map { $sum[$_] / $count } ( $h2nr->{'AU01_r'} .. $h2nr->{'AU45_r'} );
                        push @add_cols, map { $sum[$_] }          ( $h2nr->{'AU01_c'} .. $h2nr->{'AU45_c'} );
                        warn "# add_cols = ",dump( \@add_cols ) if $debug;
-                       print $out_fh join("\t", @v, @add_cols ), "\n";
+                       out_csv @v, @add_cols;
 
                        @sum = ();
                        $count = 0;