?
Solved

help parseing data

Posted on 2005-03-07
8
Medium Priority
?
327 Views
Last Modified: 2006-11-17
Begginer
From another EE expert:
Private Sub Command0_Click()

Dim intFilenum As Integer           'watch shows value 1--type interger--always 1
Dim intField As Integer             'watch shows as expected
Dim varArray(0 To 1434) As Variant  'watch shows as expected
intFilenum = FreeFile               'watch shows value 2 --type integer-- always 2
Open "c:\rTemp\aqu0207k\aqu0207.drf" For Input As #intFilenum

Do Until EOF(intFilenum)
  For intField = 0 To 1434
    Input #intFilenum, varArray(intField)
  Next

  'This is where you open your tables or invoke your queries to insert your data

Loop
Close #intFilenum

End Sub
===========================
Doing it this way means that the text fields will be stripped of their quote delimiters
automatically by the Input statement.  I used a zero-origin array for two reasons...
1. it is what the SPLIT() function would produce
2. a recordset's fields collection is zero-based

===========================
I follow some of the code.
What does freefile mean? Why this assignment intFilenum = FreeFile ?
Where are the rows? There should be 70 rows.
0
Comment
Question by:afreer2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 39

Assisted Solution

by:stevbe
stevbe earned 200 total points
ID: 13480163
FreeFile is a VBA function that returns a pointer to a file from the OS.

intFilenum is needed later on in the code to point back to file handle in the OS so you can do things like read the text from the file into a variable.

The rows are read in one at a time in ... Input #intFilenum, varArray(intField)

Do Until EOF(intFilenum)

tells the code to loop through all lines (rows) in the file until there are no more so it will work for 70 as well as any other number of rows.

Steve
0
 
LVL 54

Assisted Solution

by:nico5038
nico5038 earned 1200 total points
ID: 13480182
>What does freefile mean? Why this assignment intFilenum = FreeFile ?
When opening a file a number (Like #1, #2, etc) is required.
Th eFreeFile will return such a number that's not currently used as re-using a number in use gives an error.

The: Do Until EOF(intFilenum) will loop through all rows, the "For intField = 0 To 1434" will get the individual 1435 fields from the array.

Need more info ?

Nic;o)
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 13480247
1)What does freefile mean? Why this assignment intFilenum = FreeFile ?


FreeFile is a built in VB function that returns a pointer to the Next Free FileHandle - an internal value that serves as the pointer to the file that you are working with.  This value is an Integer, and is then used, along with the # to identify the file, in the statements:

Open "c:\rTemp\aqu0207k\aqu0207.drf" For Input As #intFilenum  ' associates the fiilehandle #intFileNum (or in you case #2 with the physical file ("c:\rTemp\aqu0207k\aqu0207.drf") and opens the handle for Input (so you can read from the file)

Do Until EOF(intFilenum)  ' continues reading from the file until an End-of-file (EOF) is reached
  For intField = 0 To 1434
    Input #intFilenum, varArray(intField)  'Inputs from the file identified by #2,
  Next
  '  you will come to these lines ONCE for each record, so you should the save the varArray or it will be over-writen by the next record
Loop


I assume that you have 1435 separate fields in each of your 70 rows?

AW
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 44

Expert Comment

by:GRayL
ID: 13480724
I'm running Access 2000 and it allows a maximum of 255 fields in a table.  If indeed you have 1435 fields per record, you are going to have to generate 6 tables to hold the data.
0
 

Author Comment

by:afreer2
ID: 13481836
I will need some time to understand what you all are showing me.

nico5038
Yes but I will ask another question.

Arthur_Wood
This is a csv file that "BRIS.com" puts out;they put 7-8 tables in one row(which is a horses history along with "todays race"
There will be as many rows as there are horses.

 GRayL
 'This is where you open your tables or invoke your queries to insert your data
This was going to be my next question.

You all answererd the question.
How do you eaperts want the pts devided?
FYI        I'm on 56k speed and I don't stay on line too long(If that makes any difference,slow responces):)

0
 
LVL 44

Expert Comment

by:GRayL
ID: 13482018
Points should be awarded on a split on the basis of how well the answer helped solve your problem.  If the answers has similar or equal value, award accordingly.  If the lions share was in one answer, and one or two others added a bit, again, award accordingly.  This is one area where you have to do the math ;))

ray
0
 
LVL 54

Assisted Solution

by:nico5038
nico5038 earned 1200 total points
ID: 13482019
There's a >Split points link at the bottom of this question allowing you to split the points.

Nic;o)
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 600 total points
ID: 13483406
as pointed out, you will need to add code, after the 1435 fields have been read for a record, to assign the values to the repsective tables, as any one table cannot have more than 255 fields.  This is where you biggest problem will be.

AW
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question