This is a fairly trivial data parsing question. I'm just unclear on the methods I should be using to pull it off.
I've got a plain text file of a few hundred lines. Each line is of exactly the same format. The lines are in contiguous chunks where the first item in a line is essentially a key that is repeated for each line in a chunk:
key0
key0
key0
...
keyN
keyN
keyN
I would like to construct an NSDictionarys directly from this file where the lines for a given key are collapsed into a dictionary. So a dictionary of dictionarys.
Any thoughts on how to do this?
Cheers, Doug
UPDATE 0 - Here's a snapshot of the actual data Here is the actual data. I can dice the file into chunks for each chr? if need be. I'm happy with a solution that ingests a single chr.
chr1 0 2300000 p36.33 gneg
chr1 2300000 5300000 p36.32 gpos25
chr1 5300000 7100000 p36.31 gneg
chr1 7100000 9200000 p36.23 gpos25
// ... // lots more // ...
chrN 144700000 148400000 q22.3 gpos100
chrN 148400000 149600000 q23.1 gneg
chrN 149600000 150300000 q23.2 gpos25
chrN 150300000 154600000 q23.3 gneg
UPDATE 1 - The File is on disk In case I didn't make it clear, the data is on disk not memory resident. I actually think I could get away with dicing the file into pieces, one for each chr. I can then ingest into an NSArray and then on into an NSDictionary. Unless of course, someone has something snazzier.