# simple way of extracting ordered lists from a text file

**URL:** <https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087>\
**Category:** Factual Questions\
**Created:** [February 18, 2008, 11:59am UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087 "2008-02-18T11:59:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![scm1001](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@scm1001](https://boards.straightdope.com/u/scm1001)\
**Post date:** [February 18, 2008, 11:59am UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/1 "2008-02-18T11:59:59Z")

</div>

I have a dictionary list (alphabetical) in text format of about 200,000 words. I want to extract all the two, three, four letter words etc separately in alphabetical order. (this is to help me learn the valid words for scrabblicious, prolific etc).

Is there a simple way of doing so (say using Word, Excel, Filemaker etc) or would I need to write a program to work on the list? I suspect many programs might struggle with the number of entries even if in principle they could reorder it in letter length.

(I know there are scrabble dictionaries out there and I have one. But these online games have their own peculiar set of words)

---

<div class="post-metadata">

**Author:** ![JustThinkin](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@JustThinkin](https://boards.straightdope.com/u/JustThinkin)\
**Post date:** [February 18, 2008, 12:59pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/2 "2008-02-18T12:59:24Z")

</div>

Simple? Dunno.

I would think you could import the list into Excel (is it tab separated?) and then run an if/then function something like this:

If contents of cell “a” is two characters long, then return those characters here.

I haven’t really used that function much, so I’m not sure how the formula would be written.

---

<div class="post-metadata">

**Author:** ![LionelHutz405](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lionelhutz405/32/536_2.png) [@LionelHutz405](https://boards.straightdope.com/u/LionelHutz405)\
**Post date:** [February 18, 2008, 1:10pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/3 "2008-02-18T13:10:51Z")

</div>

In Excel, you could use the LEN function.  
Create a column using LEN that contains the number of letters.  
Then sort on that column.  
Copy and paste to extract words of the same length.

---

<div class="post-metadata">

**Author:** ![mks57](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mks57](https://boards.straightdope.com/u/mks57)\
**Post date:** [February 18, 2008, 2:06pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/4 "2008-02-18T14:06:24Z")

</div>

This would be fairly straightforward on UNIX (also Linux, FreeBSD, Mac OS X, etc) with the standard text processing tools provided with the operating system. Off the top of my head, you could do it with _sort_ and _awk_. Sort the file with _sort_ and use _awk_ to extract the N-character words. Many of the UNIX text processing tools have been ported to other operating systems, such as Windows.

Some Perl expert will probably chime in here with a one-liner that will do the job and also do your taxes :).

---

<div class="post-metadata">

**Author:** ![iwakura43](https://avatars.discourse-cdn.com/v4/letter/i/9de0a6/32.png) [@iwakura43](https://boards.straightdope.com/u/iwakura43)\
**Post date:** [February 18, 2008, 2:20pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/5 "2008-02-18T14:20:58Z")

</div>

200,000 is more than will easily fit into Excel 2003. If you have Excel 2007, you can import the words into the first column and, as, **Lionel** says, use the LEN function to get the length of the words. If you don’t have Excel 2007, but do have Access, you can import the dictionary into a table, and then run a SELECT query where LEN([Field1]) is 2, or 3, or 4, etc., which is a little more complicated to figure out, but doable.

---

<div class="post-metadata">

**Author:** ![Joey\_P](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Joey\_P](https://boards.straightdope.com/u/Joey_P)\
**Post date:** [February 18, 2008, 2:22pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/6 "2008-02-18T14:22:55Z")

</div>

My aunt has a two and three letter word dictionary for scrabble. Looking around online, I couldn’t find it, but there are lists two and three letter words. Here’s one [Two-Letter and Three-Letter Scrabble Words](http://phrontistery.info/scrabble3.html)

---

<div class="post-metadata">

**Author:** ![scm1001](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@scm1001](https://boards.straightdope.com/u/scm1001)\
**Post date:** [February 18, 2008, 6:58pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/7 "2008-02-18T18:58:35Z")

</div>

thanks for the ideas. Only have Office 2003, so will try Access. I guess I could also first split the file into smaller chunks for Excel to work on too.

---

<div class="post-metadata">

**Author:** ![Keeve](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@Keeve](https://boards.straightdope.com/u/Keeve)\
**Post date:** [February 18, 2008, 9:55pm UTC](https://boards.straightdope.com/t/simple-way-of-extracting-ordered-lists-from-a-text-file/438087/8 "2008-02-18T21:55:57Z")

</div>

[QUOTE=iwakura43]  
If you don’t have Excel 2007, but do have Access, you can import the dictionary into a table, and then run a SELECT query where LEN([Field1]) is 2, or 3, or 4, etc., which is a little more complicated to figure out, but doable.  
[/QUOTE]  
Here’s a simpler idea, if you don’t really need the lists to be separate: Simply have the second column be the LEN(), and sort by that column first. This was your list will have everything, with the 1-letter words first, 2-letter words next, and so on.
