600 MB text files to Access - how to do it quickly?

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
So the idea is that I have now split up my 6GB flatfile into ten smaller ones, they're just text files with one ID number, four 1-10 numbers and 2400 0/1s separated by tabs there. As an example data (using only four of those 2400):

ID One Two Three A B C D
1 4 5 6 0 1 0 1
12 5 6 7 1 1 0 1

I would need to get these to Access as quickly as possible and I already have VBA code to create tables with Integer-Integer-Integer-Integer-BIT-BIT-BIT-BIT fields, but what's the smartest way to get the data there?

Let's assume one of my 600MB files is in C:\fromhere1.txt

Also, would it be faster/better if I would use ACCDB instead of MDB as my databases for this kind of data?
 
I've no idea really. But there's got to be less overhead since there's no execution of other commands intervening (FOR, IF, &, =).
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I've no idea really. But there's got to be less overhead since there's no execution of other commands intervening (FOR, IF, &, =).

Well, yours takes 15.3 seconds mine takes 36.1 seconds with 10 000 rows, so yours seems to be better - at least with 2500 columns.
 
Upvote 0
Here's the check-function I quickly built to check whether the row should be added to the sum or not.

Code:
Function bCheckCriteria(vTxtRow As Variant, vCriteria As Variant) As Boolean
    Dim i As Integer, j As Integer
    Dim iOne As Integer
    Dim iTwo As Integer
    Dim iThree As Integer
    Dim iCriteria(0 To 2) As Integer
    Dim bCheck(0 To 2) As Boolean
    
    Dim bOne As Boolean
    Dim bTwo As Boolean
    Dim bThree As Boolean
    
    iCriteria(0) = vTxtRow(1)
    iCriteria(1) = vTxtRow(2)
    iCriteria(2) = vTxtRow(3)
    
    bCheck(0) = False
    bCheck(1) = False
    bCheck(2) = False
    
    For j = LBound(bCheck) To UBound(bCheck)
        For i = LBound(vCriteria, 2) To UBound(vCriteria, 2)
            If vCriteria(j, i) = iCriteria(j) Then
                bCheck(j) = True
                Exit For
            End If
        Next i
        
        If Not bCheck(j) Then
            bCheckCriteria = False
            Exit Function
        End If
    Next j

    bCheckCriteria = True

End Function

Slightly simplified version:

Code:
Function bCheckCriteria(vTxtRow As Variant, vCriteria As Variant) As Boolean
    Dim i As Integer
        
    For i = 1 To 3
        If vCriteria(i, vTxtRow(i)) = 0 Then
            bCheckCriteria = False
            Exit Function
        End If
    Next i
    
    bCheckCriteria = True
End Function
 
Upvote 0

Forum statistics

Threads
1,225,149
Messages
6,183,188
Members
453,151
Latest member
Lizamaison

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top