Search code examples
multidimensional-arraytext-filespseudocode

How to read a text file into a multi dimensional array in pseudocode?


I have the multidimensional array: Sales (Town, Month, Product)

I have a text file containing the following:

"ABC" Jun 50 "DEF" Apr 100 "HIJ" Jun 90 "KLM" Jun 55 "NOP" Jun 65

Where the first word is Town, the second word is month & the third word is product. It then repeats for the 4-6 words, 7-9 words, etc.

How would I read my text file into the multidimensional array in pseudocode?


Solution

    1. create an list of sales.
    2. read one word and save it as town
    3. read one word and save it as month
    4. read one word and save it as product
    5. create sales object from town, month and product read on step 2, 3 and 4.
    6. add this sales object to the sales list
    7. go to step 2 if end of file is not reached yet.