This article about import data from txt document .
Step 1:
create one .txt document like below.
“mahendran”,”9003544190″
“Ramya”,”9948484884″
“krishna”, “8585885858″
and save name as test
Step 2:
create one form and name as “mahe” and create two field (i) name1 (II) mobile
save the form and map this form to one view and also map field to columns
Step3:
create one lotus script agent and paste following code
Option Public
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim uiws As New NotesUIWorkspace
Dim fileCSV As Variant
‘Declare variables to hold data
Dim Name1 As String
Dim mobile As String
Dim counter As Integer
Dim doc As NotesDocument
counter =0
’setup file number
filenum% = FreeFile()
‘Ask user for file location
fileCSV = uiws.OpenFileDialog(False, “Choose the CSV file”,”*.txt” ,”c:\temp”)
‘If the user chose a file then process
If Not IsEmpty(fileCSV ) Then
Open fileCSV(0) For Input As filenum%
Do Until EOF(filenum%)
‘Read a line of data
Input #filenum%, name1, mobile
‘Create Notes document and write values to it
Set doc = db.CreateDocument
With doc
.name1=name1
.mobile=mobile
.form=”mahe”
End With
’save document
Call doc.save(False, False)
counter = counter +1
Loop
MsgBox “You imported ” & counter & ” records.”
End If
End Sub
Step 4:
run the agent and select test.txt and go back to view you can see imported file
No comments:
Post a Comment