Which object contains a large amount of text?

I am planning a Seaside application for storing text, one instance, which can be, say, 5 MB. Which subject is best for this?

I would also like to do a few iterations over this text.

Thanks Vince

Edit: Thanks for your answers. The file is a CSV file that takes about 40 minutes to generate from the old financial system, so it must be pre-generated and saved. Each row is a client entry, and I need to pull each one out and use the values ​​when and when the client logs in. Access to the client is not predictable, and interacting with an outdated system to generate each line on the fly is the last resort.

+1
source share
4 answers

Given that the file takes a long time to generate and that you will need more or less random access to the file later on, I would prefer to parse the file and then store the structured data in memory.

Squeaksource has a CSV Parser project that you can use. It will create a structured tree of CSV record objects that you can use.

+6
source

Use an external text file and some instance of a specific class as a representation of this file. Use the oop of the object as the file name.

+3
source

Just use the customer collection and fill it out from the CSV, as Johan said. Depending on your access needs, you can use a dictionary or an ordered set to store it.

+1
source

5 megabytes is nothing. Do not worry about it.

If you cannot restore these CSV records to objects (after parsing and instantiating them), then the collection of strings or even streams will be fine.

If you need a keyword search, then a dictionary or LookupTable will do the job.

I had 100 megabytes of text data in memory (1 million lines) and was not even saved in the image (saving images) without problems.

Sincerely.

0
source

Source: https://habr.com/ru/post/910509/


All Articles