Re: Extracting info from the ASCII file with IDL [message #73585] |
Thu, 18 November 2010 08:55 |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Nov 18, 2:40 pm, Gray <grayliketheco...@gmail.com> wrote:
> Use READCOL from the NASA IDL astronomy library to read the first
> column. Then do n_elements(uniq(data,sort(data))).
Or use the built in read_ascii(). Like:
IDL> a=((read_ascii('unascii.txt')).(0))[0,*]
IDL> print,n_elements(uniq(a[sort(a)]))
4
|
|
|
Re: Extracting info from the ASCII file with IDL [message #73586 is a reply to message #73585] |
Thu, 18 November 2010 08:27  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article
<33c71657-40d7-4f24-9752-553f1ff7ec9b@j1g2000vbl.googlegroups.com>,
Sasha Singh <sashasingh.511@gmail.com> wrote:
> Hi,
> I have a ASCII text file whose entries look like this
>
> 111 AA 25 XX
> 111 AB -5 XX
> 222 AC 25 XX
> 222 AD 20 XX
> 222 AE 21 XX
> 333 AF 88 XX
> 444 AG 21 XX
> 444 AH 90 XX
> and so on.....
> In this file the first column represents a unique number refering to
> an experiment. Any particular experiment
> was repeated a random number of times, such as experiment 111 was
> repeated twice, experiment 222 was
> repeated 3 times, experiment 333 was done only once. I need to know
> how many unique experiments were done.
> To clarify it further, in above example 4 experiments (111, 222, 333
> and 444) were done. I need to know this in a file which has 1300 rows.
> Please help.
Read the file. Sort the first column. Then use UNIQ.
Ken Bowman
|
|
|
Re: Extracting info from the ASCII file with IDL [message #73587 is a reply to message #73586] |
Thu, 18 November 2010 08:40  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Nov 18, 10:38 am, Sasha Singh <sashasingh....@gmail.com> wrote:
> Hi,
> I have a ASCII text file whose entries look like this
>
> 111 AA 25 XX
> 111 AB -5 XX
> 222 AC 25 XX
> 222 AD 20 XX
> 222 AE 21 XX
> 333 AF 88 XX
> 444 AG 21 XX
> 444 AH 90 XX
> and so on.....
> In this file the first column represents a unique number refering to
> an experiment. Any particular experiment
> was repeated a random number of times, such as experiment 111 was
> repeated twice, experiment 222 was
> repeated 3 times, experiment 333 was done only once. I need to know
> how many unique experiments were done.
> To clarify it further, in above example 4 experiments (111, 222, 333
> and 444) were done. I need to know this in a file which has 1300 rows.
> Please help.
Use READCOL from the NASA IDL astronomy library to read the first
column. Then do n_elements(uniq(data,sort(data))).
|
|
|