Text File Indexing

  • Thread starter Thread starter miben
  • Start date Start date
M

miben

I have a file that is of arround 250,000 records long. Currently, I do
a simple forward only search on a record column to find the record and
return the record if found. If the record is at the bottom of the
file, it takes near 5 seconds to complete. I know if the data was in a
database, placing an index on that column is what I need to do. Is
there a way to index a column from a text file of records?
 
Hi,

AFAIK, No

That is the starting reason why there are made databases

Cor
 
cute, but unfortunately im not using a database am i? sql server is
faster then access, so if there is an access problem are you telling me
to just go get sql server? anyways...

I am going to try to load the column into memory that I want and place
it into an ArrayList to see if I can use the IndexOf method to do the
searches fatser. Then call up that row in the text file on results.
The initiaial Open method will suffer to load up the records, but the
file needs to be searched alot so this should help a little.

I am not worried about file contents changing while it is opened.
 
Miben,

You can read in your records in a datatable. Than you have inside memory the
same methods as if it was a database see this kind of pseudo code bellow

dim dt as new datatable
dt.columns.add("Mycolumn1,gettype(system.string))
etc.

While the streamreader is reading
read record
dim dr as datarow = dt.newrow
dr(1) = item1
dr(2) = item2
dt.rows.add(dr)
loop

And than you can use that datatable.

I hope this help

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top