Import Text File and Create/Update Lotus Notes Document

Hello,

I have following problem during import of TXT file in to lotus notes. This agent works fine if the column width is fixed in a txt file. But the text file which I am using to import is not having fixed width columns. I read few threads for importing txt file in to lotus notes, but could not figure out how to import the txt file which does not have a fixed width columns. I want to perform 2 operations,

During import find an document within lotus notes database, if it is existing then update the document.

Or create the document if the document is not found?

Can any one guide me what am i missing in this code?

Following is the code from an agent,

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase





filename$ = "C:\Test.txt"



Dim filenum As Integer

filenum% = Freefile()

Open filename$ For Input As fileNum%

'… Begin importing the data…

Dim newdoc As NotesDocument

docno# = 1

Do While Not Eof(fileNum%)

	Print "Importing document " + Cstr(docno#)

	Line Input #fileNum%, txt$

	Set newdoc = db.CreateDocument

	newdoc.Form = "Test1"

	newdoc.id = Trim$(Mid$(txt$, 2, 12))

	newdoc.name = Trim$(Mid$(txt$, 24, 7))		

	newdoc.company = Trim$(Mid$(txt$, 34, 8))		

	newdoc.address = Trim$(Mid$(txt$, 45, 22))

	newdoc.city = Trim$(Mid$(txt$, 70, 12))

	newdoc.state = Trim$(Mid$(txt$, 85, 2))

	newdoc.zip = Trim$(Mid$(txt$, 90, 5))

	newdoc.phone = Trim$(Mid$(txt$, 98, 12))

	newdoc.email = Trim$(Mid$(txt$, 113,15))

	newdoc.type = Trim$(Mid$(txt$, 131, 3))				

	Call newdoc.ComputeWithForm(False, False)

	Call newdoc.Save(False, False)

	docno# = docno# + 1

Loop



Close filenum%

End Sub

Subject: Import Text File and Create/Update Lotus Notes Document

But the text file which I am using to import is not having fixed width columns

What does it have, then? Comma-delimited fields? Something else? If its string-delimited, you could use the Split function to turn txt$ into an array and loop through the values, treating them appropriately.