Import Delimited File

I have had several needs to run agents a night that pull in delimited files
line by line creating new documents.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
' Dim recList List As cdmsRec
' Dim tempRec As cdmsRec
Dim linestr As String
Dim linearray () As String
Dim vararray (1 To 6) As String 'The array should be dimensioned to have
as many elements as there are separate fields on each record you're
Set db = session.CurrentDatabase

Dim collection As NotesDocumentCollection
Set collection = db.AllDocuments
If Not (db.IsFTIndexed) Then
Call db.UpdateFTIndex(True)
End If
Call collection.FTSearch("phone", 0)
If collection.Count <> 0 Then
Call collection.RemoveAll(True)
End If

filenum% = Freefile () ' Find the first free file number available
Open "C:\phones.txt" For Input As filenum% ' Open the file to be imported,
identifying it with the file number found above
recNum% = 1 ' For each line of the file, read that line into an array
element of linearray
Do While Not Eof (filenum%)
Redim Preserve linearray (recnum%)
Line Input #fileNum%, linestr
linearray (recNum%) = "% " + linestr + "%"
recNum% = recNum% + 1
Close #fileNum%

For y = 1 To Ubound(linearray) ' This will loop through each element of
linearray, which is each record in the original file
' For each record, parse the individual fields out into an array.
Since there are 38 fields in the file, loop through 38 times
position1% = 1
For x = 1 To 6
'position1% is the position of the first tilde and position2% is the second
tilde. What's between is a field value
position2% = Instr(position1% + 1, linearray(y),
vararray (x) = Mid$ (linearray (y), position1% + 1, (position2%
- position1%) - 1)
position1% = position2%
Set doc = New NotesDocument (db) ' Create a new document, setting
each field to an element of the vararray
doc.Form = "phone"
doc.LName = vararray (1)
doc.FName = vararray (2)
doc.Ext = vararray (3)
doc.Loc = vararray (4)
doc.DeptNum = vararray (5)
doc.Dept = vararray (6)
doc.ImportFlag = "Import"
Call doc.Save (True, True)

Call db.UpdateFTIndex(True)
End Sub
This was last published in November 2000

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...