Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a file which contains a set of 200000+ words and i want the program to read the data and store it in array and form a new array with all the 200000+ words
I wrote the code as

Python
import System.IO
main = do
    handle <- openFile "words.txt" ReadMode
    contents <- hGetContents handle
    con <- lines contents
    putStrLn ( show  con)
    hClose handle


But it is giving a type error as type error at line 5

And the text file is a of the form
........
ABRIDGMENT
ABRIDGMENTS
ABRIM
ABRIN
ABRINS
ABRIS
...........and so on

what are the amendments in the code that it can can form a array of words

I solved it in python with(HTH)
Python
def  readFile():
    allWords = []
    for word  in open ("words.txt"):
        allWords.append(word.strip())
    return allWords
Posted
Updated 23-Apr-14 23:27pm
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900