MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How do I take every 3rd number from a text file?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114236] Re: How do I take every 3rd number from a text file?
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Sun, 28 Nov 2010 06:53:41 -0500 (EST)
  • References: <icqfve$m3o$1@smc.vnet.net>
  • Reply-to: nma at 12000.org

On 11/27/2010 12:37 AM, cubsfan334 wrote:
> Hi,
>
> I've been reading in text files using the following command:
>
> ReadList["file.txt", Word]
>
> However, now I only want to read in every 3rd number, starting with
> the valueI specify.
>
> For example, say I had these values:
>
> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>
> How would I read in every third number, starting with the second
> integer?  So the result would look like this:
>
> 1, 4, 7
>

one way:

In[4]:= list={0,1,2,3,4,5,6,7,8,9};
list[[ Range[2, Length[list] ,3] ]]

Out[5]= {1,4,7}

--Nasser


  • Prev by Date: Re: disappointing CUDA speed
  • Next by Date: Re: How do I take every 3rd number from a text file?
  • Previous by thread: How do I take every 3rd number from a text file?
  • Next by thread: Re: How do I take every 3rd number from a text file?