# This script was excerpted from http://stackoverflow.com/questions/11678939/replace-text-based-on-a-dictionary
use strict;
use warnings;
use Text::CSV;
open my $fh, '<', 'kegg_pathway_title.txt' or die $!;
my %dict = map { chomp; split ' ', $_, 2 } <$fh>;
my $re = join '|', keys %dict;
open $fh, '<', 'Orthogroups_3.csv' or die $!;
while (<$fh>) {
next if $. < 2;
s/($re)/$dict{$1}/g;
print;
}
####
> grpsTbl <- read.csv("Orthogroups_3.csv", header=T, sep = "\t", row.names = 1, stringsAsFactors=F)
> dim(grpsTbl)
[1] 5791 13
####
> grpsTbl <- read.csv("parsed_with_perl.csv", header=T, sep = "\t", row.names = 1, stringsAsFactors=F)
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
more columns than column names