
Problem importing text file and searching for strings
Q1) In other environs, I've read so many text files in using C level;
FOPEN(), FGETS(), etc commandd to read line by line, extract data, and
insert into a table its firmly engrained in the brain. And it's fast. A
600 page report would take less than a minute to do the task. Don't know if
Access would be as fast but it should be acceptable.
Q2 Try this in debug.
strvar = "variable = Murph"
strname = right(strvar,len(strVar) - instr(strvar,"=") - 1)
This proc subtracts the length of the string from the postion of the = sign
and subtracts 1 to remove the leading space. I could have done a trim
instead of -1 instead.
I probably would read line by line. If the line has an = sign, I'd get the
left and right of the statement and then assign to a field.
Set rst = ..OpenRecordset...
FieldToUpdate = left(strvar,instr(strvar,"=")-1)
FieldValueIs = right(strvar,len(strVar) - instr(strvar,"=") - 1)
With rst
.AddNew
Select Case FieldToUpdate
Case Team
.TeamField = FieldValueIs
...
End Select
.Update
EndWith
You don't want to addnew/update for each line. Anytime you see Player,
addnew and anytime you see teamname then update.
Quote:
> Two things I need advice on:
> 1. First is will it take a long time to Input a file line by line as
> opposed to Transfertext? It takes no time at all with the TransferText
> but I still need to sort through all the records which might take time.
> 2. Second is how the heck to do the string searches :) I've seen some
> examples on this in the groups but maybe someone could help me on how to
> do a simple string search and separate the variables by the "=" sign on
> my lines and get rid of the ";" at the end of my lines.