No it won't. He wants to unpivot that thing, and what you are suggesting is to manually substitute a string of names with one name at each line.
• 1 views
•
link
this is my query:
Bm11095 Bm12884 Bm14712 Bm2854 Bm9021| |0|0|1|0| |
.
. and so on
i have a file which is pipe separated.i want to split first column in the following manner:
Bm11095| |0|0|1|0| | Bm12884| |0|0|1|0| | Bm14712| |0|0|1|0| | Bm2854| |0|0|1|0| | Bm9021| |0|0|1|0| |
You can do this with the UNIX utility sed:
sed 's/Bm11095 Bm12884 Bm14712 Bm2854 Bm9021/Bm11095/g' query > Bm11095.txt
sed 's/Bm11095 Bm12884 Bm14712 Bm2854 Bm9021/Bm12884/g' query > Bm12884.txt
[etc.]
This will make separate files like:
Bm11095.txt
Bm11095| |0|0|1|0| |
Bm12884.txt
Bm12884| |0|0|1|0| |
[etc.]
No it won't. He wants to unpivot that thing, and what you are suggesting is to manually substitute a string of names with one name at each line.
Well, yes it will... I accept that may not be what the OP wants.
I have no idea if they want to unpivot it, only that they want to "split first column of this line" - that is what the sed code will do.
Log in to answer this question.
Do you want to split this line only, or is this the header line of a file and you want to split off each column?
(PS. This kind of query might do better on http://www.stackoverflow.com)
I want to split first column of this line
Hello numita.dube!
We believe that this post does not fit the main topic of this site.
This isn't a bioinformatics question. If you want a perl script then ask in a perl forum.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
Hi,
if you are looking for a quick solution this might do the trick:
perl -lne '/(.*?)\|(.*)/;@v=split(" ", $1); foreach(@v){print "$_\|$2"}' input.file
cheers
r
thanks mxs.it worked