I want to read CSV files and create documents. The real problem is csv file is user created in which he/she can insert any between entries.Any solutions? Thanks in Advance
Subject: Read CSV File
Clean way would be to use ADO (Windows Only) (BTW…there are also JDBC drivers for .csv if you need to run it on another platform). Simple example below. reset the default dir propertyin the connection string to where the .csv file resides. Please note… if you have problems
try changing the file ext from .csv to .txt and see if that fixes the issue. Hope this helps…
Dim s as New NotesSession
Dim db as NotesDatabase
Dim conn as Variant
Dim rs as Variant
Dim sql as String
Dim doc as NotesDocument
set db = s.CurrentDatabase
set conn = CreateObject(“ADODB.Connection”)
set rs = CreateObject(“ADODB.Recordset”)
conn.ConnectionString= "Driver={Microsoft Text Driver (*.txt; *.csv)}; DefaultDir=c:\temp"
sql = “SELECT * FROM data.txt”
set rs = conn.execute(sql)
Do while not rs.EOF
set doc=db.CreateDocument
with doc
.Form = rs(0).value
.Title=rs(1).value
.Subject=rs(2).value
.save true,true
end with
rs.Next
Loop
'cleanup
conn.close
rs.close
set conn=nothing
set rs = nothing
Subject: RE: Read CSV File
some corrections on the code
rs.MoveNext 'instead of next
Loop
'cleanup
rs.close 'recordset should be close first
conn.close 'then the connection