how to read "results" files?

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

how to read "results" files?

chenyanpei
Dear all,
     I want to read the ImagJ results files,
    the code is following:
 
dirtxt=getDirectory("file name ");
listtxt = getFileList( dirtxt );
setBatchMode(true);
nbr_txt = listtxt.length;
for (i = 0; i < nbr_txt; i++)
{
showProgress(i+1, listtxt.length);
run("Results... ", "open=dirtxt+ listtxt[i]");//I try to open as a txt file, but after i open it ,the
// spacebar dispear;
filestring=File.openAsString(pathfile);
rows=split(filestring, "\n");
x=newArray(rows.length);
y=newArray(rows.length);
for(i=1; i<rows.length; i++){
columns=split(rows[i],"\t");
x[i]=parseInt(columns[1]);
y[i]=parseInt(columns[2]);
print(x[i]+" "+y[i]+"\n");
} }
    but there are some error"text.substring(7)". What is the problem? Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: how to read "results" files?

Jerome Mutterer-3
Chenyanpei,

In the following line,
>> run("Results... ", "open=dirtxt+ listtxt[i]");//I try to open as a txt
file,

the path you are feeding as a argument might contain spaces, so you need to
pass it surrounded by square braces. In addition, you are mixing strings and
variable names improperly. The command should look something like :

run("Results... ", "open=["+dirtxt+listtxt[i]+"]");

Later in your macro, you are using:
filestring=File.openAsString(pathfile);

but pathfile has not been set before that, so it will fail as well.


Sincerely,

Jerome

On Mon, Jul 5, 2010 at 10:49 AM, chenyanpei <[hidden email]> wrote:

> Dear all,
>     I want to read the ImagJ results files,
>    the code is following:
>
> dirtxt=getDirectory("file name ");
> listtxt = getFileList( dirtxt );
> setBatchMode(true);
> nbr_txt = listtxt.length;
> for (i = 0; i < nbr_txt; i++)
> {
> showProgress(i+1, listtxt.length);
> run("Results... ", "open=dirtxt+ listtxt[i]");//I try to open as a txt
> file,
> but after i open it ,the
> // spacebar dispear;
> filestring=File.openAsString(pathfile);
> rows=split(filestring, "\n");
> x=newArray(rows.length);
> y=newArray(rows.length);
> for(i=1; i<rows.length; i++){
> columns=split(rows[i],"\t");
> x[i]=parseInt(columns[1]);
> y[i]=parseInt(columns[2]);
> print(x[i]+" "+y[i]+"\n");
> } }
>    but there are some error"text.substring(7)". What is the problem? Thank
> you.
>
> --
> View this message in context:
> http://imagej.588099.n2.nabble.com/how-to-read-results-files-tp5255308p5255308.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>