changing a text file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

changing a text file

rona baron
Hello all,

I have a text file which I want to open as an image. My problem is that
right now I have a list of one column of numbers.
I need to copy the first 32 numbers and paste them to the first raw etc'..
Can I manipulte the text file to the format I need?

Any advice is appreciated,

Thanks,
Rona

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: changing a text file

Stephen Martin
this is doable with grep

e.g. for integers , creating 3 numbers per row tab-delimited, you would search for:

(\d+)\r(\d+)\r(\d+)\r

and replace with:

\1\t\2\t\3\t\r

( your end of line character(s) may differ from \r)

grep can can run from a command line or in many text editors (I use it in textwrangler on Mac OS)

regards

Steve

On 26/06/2012, at 5:06 PM, rona baron wrote:

> Hello all,
>
> I have a text file which I want to open as an image. My problem is that
> right now I have a list of one column of numbers.
> I need to copy the first 32 numbers and paste them to the first raw etc'..
> Can I manipulte the text file to the format I need?
>
> Any advice is appreciated,
>
> Thanks,
> Rona
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: changing a text file

Jerome Mutterer-3
In reply to this post by rona baron
Hi
This can also be done in python using numpy reshape function.

from numpy import *
a = array([float(line.strip()) for line in open("c:\image1d.txt")])
savetxt("c:\image2d.txt",a.reshape(-1,32), delimiter = "\t")

then use Import/Text Image...

Sincerely,
Jerome



On 26 June 2012 09:06, rona baron <[hidden email]> wrote:

> Hello all,
>
> I have a text file which I want to open as an image. My problem is that
> right now I have a list of one column of numbers.
> I need to copy the first 32 numbers and paste them to the first raw etc'..
> Can I manipulte the text file to the format I need?
>
> Any advice is appreciated,
>
> Thanks,
> Rona
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html