Re: read csv file for data by Terry
Terry
Wed Apr 06 22:58:01 CDT 2005
thanks for your help, I actually meant mdb.
"Rafael T" <okinawapro@hotmail.com> wrote in message
news:OBokopxOFHA.244@TK2MSFTNGP12.phx.gbl...
> Terry,
>
> Your post is somewhat confusing because your subject line reads "CSV file"
> but thepost mentions an mdb file.
> Usually an MDB file saves data in a different format.
>
> Assuming you want a CSV file:
> - Read the file a line at a time
> - Check if the first block of text is the one you are looking for (find
> from 0 to first ,)
> - If it matches look for the second , and grab from there till the end of
> the line
> - put the whole thing together and show it
>
> Here is a sample:
> dim fileName
> fileName=inputbox("Type path and file name","Enter info")
> set objFS=CreateObject ("Scripting.FileSystemObject")
>
> dim line
> dim IP
> set listFile = objFS.OpenTextFile (fileName)
> do while listFile.AtEndOfStream <> True
> line=listFile.ReadLine
>
> 'this line looks for the match
> if left(line,instr(line,",")-1)="200" then
>
> 'thisline concatenates the first column with the last 3
> IP=left(line,instr(line,",")-1) &
> right(line,instr(instr(line,",")+1,line,","))
> msgbox IP
> end if
> Loop
>
> *you can later on change the , with a . by doing lefts and instr or easier
> with RegularExpressions.
>
> Assuming you are working on an Access mdb file
> Use VBA and a SQL query which will make things really easy
>
> select stnumber,1sto,2nd0, 3rd0 from table where stnumber=100
>
> you can receive the result from the query in a variable and then work with
> it.
>
> hope this helps,
> RT
> "Terry" <tester@mts.net> wrote in message
> news:eqUap2uOFHA.576@TK2MSFTNGP15.phx.gbl...
>> Hello, I am looking for a script that will find data from a .mdb file if
>> the data in the first colmn match's the data that I am looking for, if it
>> finds stnumber, then assign the data from the corrisponding colums from
>> that row back to Variables in the script, the table would look like:
>>
>>
>> stnumber storename 1sto 2nd0 3rdo
>> 100 grocery 100 120 204
>>
>> there will be 200 or so rows, and if it finds the stnumber that was
>> inputed I need the next 4 colums brought back to the script to make a IP
>> address.
>>
>>
>> Thanks to anyone that takes the time to read this.
>>
>
>