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: [mg114238] Re: How do I take every 3rd number from a text file?
  • From: "Harvey P. Dale" <hpd1 at nyu.edu>
  • Date: Sun, 28 Nov 2010 06:54:03 -0500 (EST)

	Here's one way:

Flatten[Table[Take[Range[0,9],{i}],{i,2,9,3}]]

	Best,

	Harvey

Harvey P. Dale
University Professor of Philanthropy and the Law
Director, National Center on Philanthropy and the Law
139 MacDougal Street
New York, N.Y. 10012-1076


-----Original Message-----
From: cubsfan334 [mailto:cubsfan334 at gmail.com]
Sent: Saturday, November 27, 2010 3:37 AM
To: mathgroup at smc.vnet.net
Subject: [mg114238] [mg114213] How do I take every 3rd number from a text file?

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


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


  • Prev by Date: Re: Why does this pattern fail to match?
  • Next by Date: Re: Matrix Form of Quadratic Equations
  • Previous by thread: Re: 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?