Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg114227] Re: How do I take every 3rd number from a text file?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 28 Nov 2010 06:52:04 -0500 (EST)

On 11/27/10 at 3:37 AM, cubsfan334 at gmail.com (cubsfan334) wrote:

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

If you have a sufficiently large list that you cannot read the
entire list in at once you would need to create a custom routine
to read the file using Read. For smaller files, the most
efficient proceedure would be to do

Read[filename, Number][[2;;;;3]]



  • Prev by Date: Re: How do I take every 3rd number from a text file?
  • Next by Date: Re: How do I take every 3rd number from a text file?
  • 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?