Posted by
Kenton Arkill on
May 15, 2015; 6:00pm
URL: http://imagej.273.s1.nabble.com/importing-txt-into-python-script-tp5012843p5012846.html
Thanks for helping:
However in Fiji it uses Jython which has the following statement! (found in
[3] from Mark)
- *Some existing python modules can't be imported in jython.*
This is for instance the case of the module *numpy*, which would have been
really convenient for analysing data and results.
So anyway I'm playing with which at least works for a single column text
list with no headings:
Filename = "/Users/kparkill/Desktop/test.txt"
f= open(Filename, 'r')
g=f.readlines()
a= []
for line in g:
a.append(float(line))
print line
print a
On 15 May 2015 at 17:30, Zack Gainsforth <
[hidden email]> wrote:
> import numpy as np
>
> Filename = ‘whatever your file is.txt’
>
> # Create an array of numbers from the text data in the file. skip_header
> skips over the header row which will not be numbers.
> Nums = np.genfromtxt(Filename, skip_header=1)
>
> print Nums
>
> Hope that gets you started!
>
> Zack
>
> On May 15, 2015, at 6: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)
> Regards
> Kenton
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html