Posted by
Mario Faretta on
URL: http://imagej.273.s1.nabble.com/read-values-from-txt-file-tp3689457p3689460.html
if you open the file as String (File.openAsString(path);)
then you can split into rows (split(filestring. "\n");)
and then load the two columns by splitting according to the separator (tab I
suppose)
a macro doing this is written below:
pathfile=File.openDialog("Choose the file to Open:");
filestring=File.openAsString(pathfile);
rows=split(filestring, "\n");
x=newArray(rows.length);
y=newArray(rows.length);
for(i=0; i<rows.length; i++){
columns=split(rows[i],"\t");
x[i]=parseInt(columns[0]);
y[i]=parseInt(columns[1]);
}
Hope it helps
Mario
R. C. (
[hidden email]) wrote:
>
> How can I read a list of txt values from a txt file using a script or a
> macro?
>
> thanks, Alberto Perez
>
>
> (a file like this:
>
> 0 4
> 1 2
> 12 2
> 12 3
> ...
>
--
Mario Faretta
Department of Experimental Oncology
European Institute of Oncology
c/o IFOM-IEO Campus for Oncogenomics
via Adamello 16
20139 Milan
Italy
Phone: ++39-02574303054
email:
[hidden email]
http://www.ifom-ieo-campus.it[- Il Tuo 5 per Mille a favore della Ricerca dell'Istituto Europeo di
Oncologia
Tutti coloro che presentano il modello Unico, il modello 730 o più
semplicemente che ricevono dal proprio datore di lavoro il modello CUD, hanno
la facoltà di scegliere la destinazione del proprio 5 per mille.
Nella casella riservata al Finanziamento agli Enti della Ricerca Sanitaria
inserisci il codice fiscale dello IEO (08 69 14 40 153) ed apponi la Tua
firma.
Il Tuo 5 per Mille verrà destinato alla ricerca contro il cancro dell'Istituto
Europeo di Oncologia
NON COSTA NULLA E NON COMPORTA ALCUN AUMENTO DELLE IMPOSTE DA VERSARE
NON È UN'ALTERNATIVA ALL'8 PER MILLE
E' UN GESTO CONCRETO E DI GRANDE VALORE
Per saperne di più vai al sito dello IEO www.ieo.it <
http://www.ieo.it >
oppure scrivi a
[hidden email] < mailto:
[hidden email]>
Segnala ad un amico questa opportunità
-]