Nasir Islam Sujan
Nasir Islam Sujan

Reputation: 372

What will be the appropriate separator?

I have a text file which has below structure:

>hsa:9934 K04299 purinergic receptor P2Y, G protein-coupled
MINSTSTQPPDESCSQNLLITQQIIPVLYCMVFIAGILLNGVSGWIFFYVPSSKSFIIYL
KNIVIADFVMSLTFPFKILGDSGLGPWQLNVFVCRVSAVLFYVNMYVSIVFFGLISFDRY
>hsa:9934 K04299 purinergic receptor P2Y, G protein-coupled
MINSTSTQPPDESCSQNLLITQQIIPVLYCMVFIAGILLNGVSGWIFFYVPSSKSFIIYL
KNIVIADFVMSLTFPFKILGDSGLGPWQLNVFVCRVSAVLFYVNMYVSIVFFGLISFDRY

I need to load and convert this file as below tabular structure:

--------------------------------------------------------------
|>hsa:9934 K04299 purinergic receptor P2Y, G protein-coupled |
|MINSTSTQPPDESCSQNLLITQQIIPVLYCMVFIAGILLNGVSGWIFFYVPSSKSFIIYL|
|KNIVIADFVMSLTFPFKILGDSGLGPWQLNVFVCRVSAVLFYVNMYVSIVFFGLISFDRY|
--------------------------------------------------------------
|>hsa:9934 K04299 purinergic receptor P2Y, G protein-coupled |
|MINSTSTQPPDESCSQNLLITQQIIPVLYCMVFIAGILLNGVSGWIFFYVPSSKSFIIYL|
|KNIVIADFVMSLTFPFKILGDSGLGPWQLNVFVCRVSAVLFYVNMYVSIVFFGLISFDRY|
--------------------------------------------------------------

I tried below code:

dataset = pd.read_csv(path, sep = ">")

But it doesn't worked as I expected!

How can I get the exact format?

Upvotes: 0

Views: 37

Answers (1)

oneindelijk
oneindelijk

Reputation: 636

you could use str.split('>') so you end up with an array for each value. Unless '>' might appear in the hashes

Upvotes: 2

Related Questions