Re: importing txt into python script
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
May 15, 2015; 6:07pm
URL: http://imagej.273.s1.nabble.com/importing-txt-into-python-script-tp5012843p5012847.html
> On May 15, 2015, at 9:08 AM, Kenton Arkill <
[hidden email]> wrote:
>
> Hi
> I'm a newby at python/jython. I wish to import txt files and make them
> lists of numbers so I can do things with them. my txt files are 2 columns
> and lots of rows (with header name) and tab delimited.
> Any help appreciated (eg a pointer to the right place to find it)
Open the tab-delmited text file as a ResultsTable and then use the getValue() method to retrieve the values. The following JavaScript example opens a two column (“Min” and “Max”) tab-delmited text file as a ResultsTable and retrieves and prints the values.
-wayne
rt = ResultsTable.open("/Users/wayne/Results.txt");
for (i=0; i<rt.size(); i++) {
min = rt.getValue("Min", i);
max = rt.getValue("Max", i);
print(i+" "+min+" "+max);
}
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html