Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to pull specific data from a table.

Status
Not open for further replies.

Pandab2002

IS-IT--Management
Apr 16, 2003
47
US
I am importing a csv file to a table in Access. It contains over 2000 rows and 16 fields (cloumns). I am only concerned with certain data in Field 1 and Field 2. Here is a sample of that data:

SiteName Hurst TX
UserSiteID 101
Partition 1
DateRetrieved 12/21/2004 13:25

Node Statistics accumulated since 08 MAR 2004 03:59:40
PARTITION #1
Node Access Counts
NODE # MSG
1 24491
2 1299
3 589
4 29358
5 2368
6 0
7 35852
8 1617
9 1996
10 119
11 28589
12 4207
13 3067
14 6327
15 10083
16 10602
17 828
18 217
19 450
20 36
21 848
22 64
23 94
24 361
25 0
26 0
984
985
986
999

Line Statistics accumulated since 08 MAR 2004 03:59:39
Line Call Counts
CARD/LINE LINE 1
CARD 1 33196
CARD 2 0
CARD 3
CARD 4
CARD 5
CARD 6
CARD 7
CARD 8

AUTO Selection Counts
AUTO node # 1
Invalid Count 1099
Abort Count 221
Timeout Count 1193
Star Count 1432
Pound Count 0
6100-6199:XFER 1 27
6600-6699:XFER 1 171
2-2:DTMF 4 1631
3-3:CMD 2 8883
4-4:CMD 3 3472
5-5:CMD 4 554
6-6:XFER 3 1395
7-7:DTMF 15 315
8-8:XFER 2 6853
0-0:XFER 2 4437

VOX Selection Counts

TABLE Selection Counts
TABLE node # 92
Continue Count 0
Invalid Count 24
10:00-20:00:DTMF 98 325



What I want to be able to do is to pick certain data out of this. Specifically, SiteName, UserSiteID, DateRetrieved and then the following:

AUTO node # 1
Invalid Count 1099
Abort Count 221
Timeout Count 1193
Star Count 1432
Pound Count 0
6100-6199:XFER 1 27
6600-6699:XFER 1 171
2-2:DTMF 4 1631
3-3:CMD 2 8883
4-4:CMD 3 3472
5-5:CMD 4 554
6-6:XFER 3 1395
7-7:DTMF 15 315
8-8:XFER 2 6853
0-0:XFER 2 4437

After I get this data, I need to save it in a table that uses the UserSiteID as the table name. (In this case 101).
Can anyone assist?

Thanks very much and Merry Christmas.
 
Since your import data doesn't appear to have any consistent structure you are probably stuck with reading it line-by-line and parsing out the specific lines that you want. Here's a way to begin
Code:
Dim TheString          As String
Dim TakeEverythingElse As Boolean
Dim nH as Integer

nH = FreeFile
Open "myfile.txt" For Input As #nH
TakeEverythingElse = False

Do Until EOF(nH)
   Input Line #nH, TheString
   If TakeEverythingElse Then
      [COLOR=green]' Handle the lines in the "AUTO node #" section[/color]

   Else

      If Instr ( TheString, "SiteName" ) > 0 Then
         [COLOR=green]' Save the Site Name[/color]
      ElseIf Instr ( TheString, "UserSiteID") > 0 Then
         [COLOR=green]' Save the User Site ID[/color]
      ElseIf Instr ( TheString, "DateRetrieved") > 0 Then
         [COLOR=green]' Save the Date Retrieved[/color]
      ElseIf Instr ( TheString, "AUTO node #") > 0 Then
         [COLOR=green]' Save the Auto Node #[/color]
         [COLOR=green]' Set the flag to Read all remaining values[/color]
         TakeEverythingElse = True
      End If     
   End If
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top