I have 32 CSV files containing fetched information from a database. I need to make a frequency table in TSV/CSV format, where the names of the rows are the name of each file, and the names of the columns are the unique names found throughout the files. The table then needs to be populated with the frequency count of each name for each file. The biggest problem is that not all files contain the same fetched names.
.csv
input:
$cat file_1
name_of_sequence,C cc,'other_information'
name_of_sequence,C cc,'other_information'
name_of_sequence,C cc,'other_information'
name_of_sequence,D dd,'other_information'
...
$cat file_2
name_of_sequence,B bb,'other_information'
name_of_sequence,C cc,'other_information'
name_of_sequence,C cc,'other_information'
name_of_sequence,C cc,'other_information'
...
$cat file_3
name_of_sequence,A aa,'other_information'
name_of_sequence,A aa,'other_information'
name_of_sequence,A aa,'other_information'
name_of_sequence,A aa,'other_information'
...
$cat `.csv/.tsv` output:
taxa,A aa,B bb,C cc,D dd
File_1,0,0,3,1
File_2,0,1,3,0
File_3,4,0,0,0
Using bash I know how to cut
the second column, sort
and uniq
the names, and then obtain a count for each name in each file. I do not know how to make a table that will show all the names, counts and place a "0 when the name does not exist in the file". I normally sort data with Bash, but a python script can also work.