Albert,Weeks,"Albert Weeks" <email@example.com>,653-909-2020,...
You can use the Split function in LotusScript to change it into an array with the value for each field being at the same array index on each row. E.g.:
Line Input #fn, strLine Do Until strLine = "" arrFields = Split(strLine, ",") Dim docNew As New NotesDocument(db) docNew.Form = "Person" docNew.FirstName = arrFields docNew.LastName = arrFields ... docNew.Save Line Input #fn, strLine Loop
And so on (I've left out some details of variable declarations, getting the db object, etc.). Of course, sometimes you encounter .CSV files where every string is in quotes and if there are quotes in the data, they are escaped. E.g.:
"Albert","Weeks","""Weeks, Albert"" <firstname.lastname@example.org>","653-909-2020",...
This can still be done but it's harder to code because you can't just Split on the commas -- some of the commas are part of the data. You have to parse the string one character at a time and keep track of whether you are inside of quotes, to know when you have reached the end of a field.
You can also import a .CSV file into a Notes view using the File -> Import function from the menu. However, this requires that the .CSV file be in a format that matches the view, and this may not be convenient to arrange.
Yet another option, if you have a copy of LEI (Lotus Enterprise Integrator), is to use a "Direct Transfer" activity to move data between a "Text connection" (your file) and a "Notes connection" (your Notes database). This doesn't require any programming, but it does require that you supply a "ZID" description of the contents of the .CSV file. The ZID format is described in the Domino Designer help, and is simple if the file doesn't contain fancy formatting, but probably not possible if the data contains escaped quotes and commas, as in the second example above.
If you don't have LEI, you can still use the Text connector to pull your data from the file and the Notes connector to insert it into Notes, but then you're back to programming, and it's probably just as easy to parse the data yourself as described above.
Do you have comments on this Ask the Expert question and response? Let us know.
Dig Deeper on LotusScript
Related Q&A from Andre Guirard
Learn how you can use LotusScript and OLE to create and populate Microsoft Excel spreadsheets, as well as a little bit about Lotus Symphony. Continue Reading
Discover options you can use if you'd like external users to be able to access a workflow-based Notes Domino application through different ... Continue Reading
Learn why you may receive the error message: "Illegal circular use: Audit Trail" when trying to open Lotus Notes documents that use copied forms. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.