替换 ^ 和 |矩阵中的符号
我有下表:
column1 column2
1 aaa^bbb
2 aaa^bbb|ccc^ddd
我想要一个输出文件,如下所示:
column1 column2 column3
1 aaa bbb
2 aaa bbb
3 ccc ddd
您介意让我知道是否有聪明的方法可以做到这一点吗?
更新:
我试图做两件事;
对于 ^,我想将上下文分隔到第 2 列和第 3 列。
对于 |,我想将其分隔到下一行,但在第 1 列中保留相同的数字(第 1 列对于第 2 行和第 3 行是相同的。抱歉我这里写错
了,输入如下:
column1 column2
x aaa^bbb
y aaa^bbb|ccc^ddd
输出如下:
column1 column2 column3
x aaa bbb
y aaa bbb
y ccc ddd
I have the following table:
column1 column2
1 aaa^bbb
2 aaa^bbb|ccc^ddd
I would like to have a output file as follows:
column1 column2 column3
1 aaa bbb
2 aaa bbb
3 ccc ddd
Could you mind to let me know if there are smart way of doing this?
Update:
I was trying to do two things;
For ^, I want to separate the context to the column 2 and column 3.
For |, I want to separate it to the next row, but keeping the same number in column1 (the column1 is the same for row 2 and 3. Sorry that I make a mistake here.
To rewrite, input is as follows:
column1 column2
x aaa^bbb
y aaa^bbb|ccc^ddd
Output is as follows:
column1 column2 column3
x aaa bbb
y aaa bbb
y ccc ddd
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
完成您想要的操作的最简单方法就是使用
strsplit
。例如,您可能可以结合拆分步骤,但我对您的数据格式没有足够的了解,无法确信它始终有效。
The easiest way to do what you are after, is just use
strsplit
. For example,You could probably combine the splitting step, but I don't have enough knowledge to your data format to be confident that it will always work.