I have a text file like this:
Viruses/GCF_000820355.1_ViralMultiSegProj14361_genomic.fna.gz
Sclerophthora macrospora virus A
Viruses/GCF_000820495.2_ViralMultiSegProj14656_genomic.fna.gz
Influenza B virus RNA
Viruses/GCF_000837105.1_ViralMultiSegProj14079_genomic.fna.gz
Tomato mottle virus
And I need to get a csv file like this:
Viruses/GCF_000820355.1_ViralMultiSegProj14361_genomic.fna.gz,Sclerophthora macrospora virus A
Viruses/GCF_000820495.2_ViralMultiSegProj14656_genomic.fna.gz,Influenza B virus RNA
Viruses/GCF_000837105.1_ViralMultiSegProj14079_genomic.fna.gz,Tomato mottle virus
Because later I want to use this like a tuple to find the compressed file, read it and get a final file with names like:
Viruses/GCF_000837105.1/Tomato mottle virus.fna
I just need to learn how to do the first part of the problem. It could by with:
- sed
- awk
- R
- Python
Any help would be very appreciated. This is hard for me to accomplish because the original filenames are very messed up.
I have tried this:
sed -z 's/\n/,/g;s/,$/\n/' multi_headers
However it put comma in all \n.