I have a file containing numbers in a column like:
10.5
16.3
15.7
2.3
46.8
3.3
.
.
.
and I was wondering if there was a way to make it show up in an array form like:
10.5 2.3
16.3 46.8
15.7 3.3
Let's say I want to make a new column every 100 values. How can I do that and be able to copy and paste the values into individual cells in MS Excel? If it's not possible, let me know too.
The 'paste' command slides files together, so you just need scripts to select the right and left columns. You too 3 and 3, but then you have ..., so is it 3 or half or ? You can pipe together the two file generators to pipe so there is no delay, temp file space limit or extra i/o overhead.
Oh sorry, those are decimal values. Let me give a better example of what I want to do.
I have a file that contains:
1
2
3
4
5
6
7
8
9
and I want to make a file that contains:
1 2 3
4 5 6
7 8 9
and for me to be able to copy that 3 by 3 array and paste it into a 3 by 3 table in excel.
Are you saying the 'paste' command will make a new file with data from each file displayed side by side? If so, is there a way I can take a file and make new files containing every 100 lines of the original file?
I suppose a simple shell script could count lines read and print thos modulo 100 = 1, 2, or 0.
ct=0
while read l
do
if (( ct % 100 == 1 ))
then
echo "$l"
fi
done <in_file
If you don't like/have pipes <(...), you can collect each 300 lines in an array and print them out in your order.
You could prefix each line with the order you need them in (1, 4, 7, . . . 298, 2, 5, 8, . . . 299, 3, 6, 9, . . . 300, 301, 304, . . . .), sort -n them all and process the output three lines into one:
while read n l1
do
read n l2
read n l3
echo "$l1 $l2 $l3"
done
It'd make a handy C app, just give it a width and length, and it can fputs the M lines to N tmpfile() FILE*'s, rewind, print, rewind, repeat.