拆分多列列 [英] split a column in multiple columns
问题描述
我是相当新的awk的,它是我问我的第一个问题。如果我的问题已经回答请直接我是正确的。谢谢。到目前为止,我没有找到一个解决办法我也没有设法达到我想要的输出。
假设我有科学数据,排列在单个列中的所有数字,但由米(高)重新present N(宽度)的强度矩阵。输入文件的列总共有n * m个行。输入例子可能看起来像:
I am fairly new to awk and it's my first question I am asking. In case my problem was already answered please direct me to the right one. Thanks. So far I neither found a solution nor did I manage to achieve the output I want. Let's assume I have scientific data, all numbers arranged in a single column but represent an intensities matrix of n(width) by m(height). The column of the input file has in total n*m rows. An input example may look like that:
1结果
2结果
3结果
......结果
30
1
2
3
......
30
新的输出应该是这样的,我有m行N新列。坚持我的例子有30场的输入和N = 3,M = 10,我需要这样的一个输出文件(分隔符没多大关系,可能是一个空格,制表符等):
The new output should be such that I have n new columns with m rows. Sticking to my example with 30 fields input and n=3, m=10 I would need an output file like this (seperator does not matter much, could be a blank, a tab etc.):
1 11 21结果
2 12月22日结果
... ... ....结果
10 20 30
1 11 21
2 12 22
... ... ....
10 20 30
我使用的是Windows下的GAWK。请注意,没有特殊的FS,更真实的exsampls像60 * 60或更大。感谢所有答案或建议。
I use gawk under Windows. Please note that there are no special FS, more real-world exsampls are like 60*60 or bigger. Thanks for all answers or advice.
推荐答案
如果你不局限于 AWK
,但有GNU核心utils的的(Cygwin的,原生,..)的那么简单的解决方法是使用新闻
:
If you are not limited to awk
but have GNU core-utils (cygwin, native, ..) then the simplest solution is to use pr
:
pr -ts" " --columns 3 file
这篇关于拆分多列列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!