Hello ImageJ developers and contributors,
Firstly, this is a fantastic program and I have been using it extensively. Thank you. Computer specs: Windows 7 professional, 16 GB of ram, ImageJ v1.47i (I have 14000 MB enabled for ImageJ use). I'm in the process of writing a macro that reads an excel file and separates data by worksheet. (and then processes this information further). I have to do this by creating a VBscript file that reads the excel file, transfers it to a text file, and then ImageJ would do the rest. (this may not be the best route, but it's what I have so far). Everything works great, until I use File.openAsString(path). The excel files that I'm working with produce text files of ~15,000 character length, but File.openAsString(path) is only reading the first ~3000 index. Are there limits on strings of which I'm unaware? Maybe some problems working with Windows 7? I know that if the file is not a .txt extension, File.openAsRawString only opens the first 5000 bytes, but I was under the impression that the File.OpenAsString(path) should transfer all the information as a string. Attached is my macro. I have placed an exit() to where I have it developed. Ignore the rest because it may need further debugging. I've already written several macros, but I'm really stumped on this one. Any help would be fantastic. -- Luke Johnson Cleveland State University. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Like,
On Wed, 6 Feb 2013, Luke Johnson wrote: > I'm in the process of writing a macro that reads an excel file and > separates data by worksheet. (and then processes this information > further). I have to do this by creating a VBscript file that reads the > excel file, transfers it to a text file, and then ImageJ would do the > rest. (this may not be the best route, but it's what I have so far). > > Everything works great, until I use File.openAsString(path). The excel > files that I'm working with produce text files of ~15,000 character > length, but File.openAsString(path) is only reading the first ~3000 > index. The macro language is not really a good choice for such heavy-lifting. It limits the string to 5,000 bytes by default: http://mirror.imagej.net/developer/macro/functions.html#File.openAsString Maybe you need to use File.openAsRawString(path, limit)? But again, the macro language is the wrong choice for this. Javascript or Java seem the best choice to me here. Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Could you open the file as an image? This would provide unlimited length.
_________________________________________ Michael Cammer, Assistant Research Scientist Skirball Institute of Biomolecular Medicine Lab: (212) 263-3208 Cell: (914) 309-3270 ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of Johannes Schindelin [[hidden email]] Sent: Wednesday, February 06, 2013 4:14 PM To: [hidden email] Subject: Re: String length limit? Hi Like, On Wed, 6 Feb 2013, Luke Johnson wrote: > I'm in the process of writing a macro that reads an excel file and > separates data by worksheet. (and then processes this information > further). I have to do this by creating a VBscript file that reads the > excel file, transfers it to a text file, and then ImageJ would do the > rest. (this may not be the best route, but it's what I have so far). > > Everything works great, until I use File.openAsString(path). The excel > files that I'm working with produce text files of ~15,000 character > length, but File.openAsString(path) is only reading the first ~3000 > index. The macro language is not really a good choice for such heavy-lifting. It limits the string to 5,000 bytes by default: http://mirror.imagej.net/developer/macro/functions.html#File.openAsString Maybe you need to use File.openAsRawString(path, limit)? But again, the macro language is the wrong choice for this. Javascript or Java seem the best choice to me here. Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Luke Johnson
On Feb 6, 2013, at 2:01 PM, Luke Johnson wrote:
> Hello ImageJ developers and contributors, > > Firstly, this is a fantastic program and I have been using it extensively. > Thank you. > > Computer specs: Windows 7 professional, 16 GB of ram, ImageJ v1.47i (I have > 14000 MB enabled for ImageJ use). > > I'm in the process of writing a macro that reads an excel file and > separates data by worksheet. (and then processes this information > further). I have to do this by creating a VBscript file that reads the > excel file, transfers it to a text file, and then ImageJ would do the > rest. (this may not be the best route, but it's what I have so far). > > Everything works great, until I use File.openAsString(path). The excel > files that I'm working with produce text files of ~15,000 character length, > but File.openAsString(path) is only reading the first ~3000 index. Are > there limits on strings of which I'm unaware? Maybe some problems working > with Windows 7? I know that if the file is not a .txt extension, > File.openAsRawString only opens the first 5000 bytes, but I was under the > impression that the File.OpenAsString(path) should transfer all the > information as a string. File.openAsString() can open files of any length if you upgrade to the ImageJ 1.47j daily build. -wayne > Attached is my macro. I have placed an exit() to where I have it > developed. Ignore the rest because it may need further debugging. I've > already written several macros, but I'm really stumped on this one. Any > help would be fantastic. > > -- > Luke Johnson > Cleveland State University. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Wayne Rasband,
The daily build in Imagej 1.47j did not solve the problem of opening files of any length with File.openAsString(). Still is only opening 5000 bytes. I guess my next step is to build a java file from scratch? -Luke. On Wed, Feb 6, 2013 at 9:43 PM, Rasband, Wayne (NIH/NIMH) [E] < [hidden email]> wrote: > On Feb 6, 2013, at 2:01 PM, Luke Johnson wrote: > > > Hello ImageJ developers and contributors, > > > > Firstly, this is a fantastic program and I have been using it > extensively. > > Thank you. > > > > Computer specs: Windows 7 professional, 16 GB of ram, ImageJ v1.47i (I > have > > 14000 MB enabled for ImageJ use). > > > > I'm in the process of writing a macro that reads an excel file and > > separates data by worksheet. (and then processes this information > > further). I have to do this by creating a VBscript file that reads the > > excel file, transfers it to a text file, and then ImageJ would do the > > rest. (this may not be the best route, but it's what I have so far). > > > > Everything works great, until I use File.openAsString(path). The excel > > files that I'm working with produce text files of ~15,000 character > length, > > but File.openAsString(path) is only reading the first ~3000 index. Are > > there limits on strings of which I'm unaware? Maybe some problems > working > > with Windows 7? I know that if the file is not a .txt extension, > > File.openAsRawString only opens the first 5000 bytes, but I was under the > > impression that the File.OpenAsString(path) should transfer all the > > information as a string. > > File.openAsString() can open files of any length if you upgrade to the > ImageJ 1.47j daily build. > > -wayne > > > > Attached is my macro. I have placed an exit() to where I have it > > developed. Ignore the rest because it may need further debugging. I've > > already written several macros, but I'm really stumped on this one. Any > > help would be fantastic. > > > > -- > > Luke Johnson > > Cleveland State University. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Luke Johnson -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Luke,
On Fri, 15 Feb 2013, Luke Johnson wrote: > The daily build in Imagej 1.47j did not solve the problem of opening > files of any length with File.openAsString(). Still is only opening > 5000 bytes. I guess my next step is to build a java file from scratch? Or you could use my suggestion, of course. This macro outputs '1235930' for me (the size of my local a2.mov file): x = File.openAsRawString("/tmp/a2.mov", 9999999); print(lengthOf(x)); But maybe you have good reasons not to try my suggestion? :-) Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Luke Johnson
Luke,
I don't know how large your files are, but I just loaded a text consisting of nearly 40000 chars to the ImageJ Log window by calling the macro routine File.openAsString(""); This was with the final ImageJ release 1.47j on an old PPC-Mac (OSX 10.4.11) with 32bit Java 1.5.0_19. Best Herbie On 15.02.13 19:34, Luke Johnson wrote: > Wayne Rasband, > > The daily build in Imagej 1.47j did not solve the problem of opening files > of any length with File.openAsString(). Still is only opening 5000 bytes. > I guess my next step is to build a java file from scratch? > > -Luke. > > > On Wed, Feb 6, 2013 at 9:43 PM, Rasband, Wayne (NIH/NIMH) [E]< > [hidden email]> wrote: > >> On Feb 6, 2013, at 2:01 PM, Luke Johnson wrote: >> >>> Hello ImageJ developers and contributors, >>> >>> Firstly, this is a fantastic program and I have been using it >> extensively. >>> Thank you. >>> >>> Computer specs: Windows 7 professional, 16 GB of ram, ImageJ v1.47i (I >> have >>> 14000 MB enabled for ImageJ use). >>> >>> I'm in the process of writing a macro that reads an excel file and >>> separates data by worksheet. (and then processes this information >>> further). I have to do this by creating a VBscript file that reads the >>> excel file, transfers it to a text file, and then ImageJ would do the >>> rest. (this may not be the best route, but it's what I have so far). >>> >>> Everything works great, until I use File.openAsString(path). The excel >>> files that I'm working with produce text files of ~15,000 character >> length, >>> but File.openAsString(path) is only reading the first ~3000 index. Are >>> there limits on strings of which I'm unaware? Maybe some problems >> working >>> with Windows 7? I know that if the file is not a .txt extension, >>> File.openAsRawString only opens the first 5000 bytes, but I was under the >>> impression that the File.OpenAsString(path) should transfer all the >>> information as a string. >> >> File.openAsString() can open files of any length if you upgrade to the >> ImageJ 1.47j daily build. >> >> -wayne >> >> >>> Attached is my macro. I have placed an exit() to where I have it >>> developed. Ignore the rest because it may need further debugging. I've >>> already written several macros, but I'm really stumped on this one. Any >>> help would be fantastic. >>> >>> -- >>> Luke Johnson >>> Cleveland State University. >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |