我有一大组文本文件,它们目前在单列中,每行代表一个 fMRI
session 的时间点。
我现在想将这一列拆分为多列,以便我可以制作信号的时间序列。
所以,例如: 一个文本文件有 351 行(时间点)。 我的实验包括 8 个 40 卷 block ,以及额外的 31 卷休息期(即 8*40+31=351)。 现在,我想将此文本文件转换为以下格式:
8(w)x40(h)+1x31...
即,
a
b
c
d
e
f
到
a d
b e
c f
提前感谢您的所有帮助!
最佳答案
对于您的示例,这是可行的:
split -l 3 file0 # split file into chunks of 3 lines
nl xaa > file1 # add linecount for join
nl xab > file2
join file1 file2 > pre # join based on linecount colum
sed 's/ *[0-9]*.//' pre > result # remove linecount colum
但是 123 的评论 (xargs -n3 < file) 提出的解决方案要简单得多,结果只会产生一个转置表!
关于linux - 将单列文本文件编辑为多列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35310913/