SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

 
 

perl-Text-CSV-Pivot rpm build for : OpenSuSE. For other distributions click perl-Text-CSV-Pivot.

Name : perl-Text-CSV-Pivot
Version : 0.09 Vendor : obs://build_opensuse_org/devel:languages:perl
Release : lp156.1.1 Date : 2024-07-03 19:13:39
Group : Development/Libraries/Perl Source RPM : perl-Text-CSV-Pivot-0.09-lp156.1.1.src.rpm
Size : 0.04 MB
Packager : https://www_suse_com/
Summary : Transform CSV file into Pivot Table format
Description :
Recently I was asked to prepare pivot table using csv file at work. Having
done that using quick and dirty perl script, I decided to clean up and make
it generic so that others can also benefit.

Below is sample data, I used for prototype as source csv file.

+----------------+-----------+--------+--------+
| Student | Subject | Result | Year |
+----------------+-----------+--------+--------+
| Smith, John | Music | 7.0 | Year 1 |
| Smith, John | Maths | 4.0 | Year 1 |
| Smith, John | History | 9.0 | Year 1 |
| Smith, John | Language | 7.0 | Year 1 |
| Smith, John | Geography | 9.0 | Year 1 |
| Gabriel, Peter | Music | 2.0 | Year 1 |
| Gabriel, Peter | Maths | 10.0 | Year 1 |
| Gabriel, Peter | History | 7.0 | Year 1 |
| Gabriel, Peter | Language | 4.0 | Year 1 |
| Gabriel, Peter | Geography | 10.0 | Year 1 |
+----------------+-----------+--------+--------+

I aim to get something like this below.

+----------------+--------+-----------+---------+----------+-------+-------+
| Student | Year | Geography | History | Language | Maths | Music |
+----------------+--------+-----------+---------+----------+-------+-------+
| Gabriel, Peter | Year 1 | 10.0 | 7.0 | 4.0 | 10.0 | 2.0 |
| Smith, John | Year 1 | 9.0 | 9.0 | 7.0 | 4.0 | 7.0 |
+----------------+--------+-----------+---------+----------+-------+-------+

With the help of Text::CSV::Pivot, I came up with the following solution.

use strict; use warnings;
use Text::CSV::Pivot;

Text::CSV::Pivot->new({ input_file => \'sample.csv\',
col_key_idx => 0,
col_name_idx => 1,
col_value_idx => 2 })->transform;

After executing the above code, I got the expected result in
\'sample.pivot.csv\'.

RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/15.6/noarch

Content of RPM  Provides Requires

Download
ftp.icm.edu.pl  perl-Text-CSV-Pivot-0.09-lp156.1.1.noarch.rpm
     

Provides :
perl(Text::CSV::Pivot)
perl-Text-CSV-Pivot

Requires :
/usr/bin/perl
perl(:MODULE_COMPAT_5.26.1)
perl(Getopt::Long) >= 2.48
perl(Text::CSV) >= 1.33
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1


Content of RPM :
/usr/bin/csv-pivot
/usr/lib/perl5/vendor_perl/5.26.1/Text
/usr/lib/perl5/vendor_perl/5.26.1/Text/CSV
/usr/lib/perl5/vendor_perl/5.26.1/Text/CSV/Pivot.pm
/usr/lib/perl5/vendor_perl/5.26.1/x86_64-linux-thread-multi
/usr/share/doc/packages/perl-Text-CSV-Pivot
/usr/share/doc/packages/perl-Text-CSV-Pivot/Changes
/usr/share/doc/packages/perl-Text-CSV-Pivot/README
/usr/share/licenses/perl-Text-CSV-Pivot
/usr/share/licenses/perl-Text-CSV-Pivot/LICENSE
/usr/share/man/man3/Text::CSV::Pivot.3pm.gz

 
ICM