Kuba
asked on
I want to import address data
I am using Notes 4.6. We have several .csv files that contain address data (the fields and field names are unique in each .csv file). I would like to be able to import each file into my persaonl address book and into a particular category. To further complicate matters I wuld also like the ability to either append or overwrite any data that already exists in that given category. Is this easily doable?
ASKER
I guess I am looking for code or some direction. Assuming the answer is that I can do what i want I then need to know *how* to do it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Code to archive database
Dim archiveDb As New NotesDatabase( "", "" )
Dim doc As NotesDocument
If ( doc.Form= "Person" ) Then
Call doc.CopyToDatabase( archiveDb )
End If
Code for the agent that reads the csv file
Type RecType
empId As Double
employee As String
End Type
Dim arrayOfRecs() As RecType
Dim txt As String
Dim fileNum As Integer
Dim counter As Integer
Dim countRec As Integer
fileNum% = FreeFile()
counter% = 0
Open "c:\My Documents\Test.csv" For Input As fileNum%
Do While Not EOF(fileNum%)
Line Input #fileNum%, txt$
counter% = counter% + 1
Loop
Seek fileNum%, 1
ReDim arrayOfRecs(1 To counter%)
For countRec% = 1 To counter%
Input #fileNum%, arrayOfRecs(countRec%).emp loyee$, _
arrayOfRecs(countRec%).emp Id#
Employee=arrayofRecs(count Rec%).empl oyee$
EmpId=arrayofRecs(countRec %).empId#
dim newdoc as notesdocument
newdoc.form="Person"
newdoc.Firstname(0)=Employ ee
set newdoc=db.createdocument
call newdoc.save(true,true)
Next
Close fileNum%
Print arrayOfRecs(2).employee$ & " " arrayOfRecs(2).empId#
Hi Kuba,
I have written the code for the agent too. All the best.
Dim archiveDb As New NotesDatabase( "", "" )
Dim doc As NotesDocument
If ( doc.Form= "Person" ) Then
Call doc.CopyToDatabase( archiveDb )
End If
Code for the agent that reads the csv file
Type RecType
empId As Double
employee As String
End Type
Dim arrayOfRecs() As RecType
Dim txt As String
Dim fileNum As Integer
Dim counter As Integer
Dim countRec As Integer
fileNum% = FreeFile()
counter% = 0
Open "c:\My Documents\Test.csv" For Input As fileNum%
Do While Not EOF(fileNum%)
Line Input #fileNum%, txt$
counter% = counter% + 1
Loop
Seek fileNum%, 1
ReDim arrayOfRecs(1 To counter%)
For countRec% = 1 To counter%
Input #fileNum%, arrayOfRecs(countRec%).emp
arrayOfRecs(countRec%).emp
Employee=arrayofRecs(count
EmpId=arrayofRecs(countRec
dim newdoc as notesdocument
newdoc.form="Person"
newdoc.Firstname(0)=Employ
set newdoc=db.createdocument
call newdoc.save(true,true)
Next
Close fileNum%
Print arrayOfRecs(2).employee$ & " " arrayOfRecs(2).empId#
Hi Kuba,
I have written the code for the agent too. All the best.
ASKER
Wow that looks great! Of course I don't understand much of it :)
I'd like to keep the question open a bit in case I have implementation problems (I assume I have to modify the script for my environment). If I don't get around to this soon I'll close out the question with this as the answer.
I'd like to keep the question open a bit in case I have implementation problems (I assume I have to modify the script for my environment). If I don't get around to this soon I'll close out the question with this as the answer.
ASKER
Answer accepted
You can do that by using script only, there is no other way to achieve this easily.
If I am correct are you looking for sample code.???
~Hemanth