Home > Ask the Domino Experts > Domino Development Questions & Answers > Personal doc in public address book from data in .CSV file
Ask The Domino Expert: Questions & Answers
EMAIL THIS

Personal doc in public address book from data in .CSV file

Andre Guirard EXPERT RESPONSE FROM: Andre Guirard

Pose a Question
Other Domino Categories
Meet all Domino Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 25 January 2005
I have a small application where I have to create a personal document in the public address book from data in a .CSV file. Can you please help me?

>
This is perfectly possible, and you can do it with LotusScript using the Line Input# statement to read a line at a time, and then parse the line in your code. How easy this is depends in large part on how the .CSV file is formatted. It's easier to work with a file that just has plain values separated with commas:

Albert,Weeks,"Albert Weeks" <aweeks@somewhat.org>,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[0]
docNew.LastName = 
arrFields[1]
...
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"" <aweeks@somewhat.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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Domino Development
Can I create and copy Microsoft Excel spreadsheets with LotusScript?
'Illegal circular use: Audit Trail' error when opening Lotus Notes docs
How to make computed fields recalculate
Sending and logging faxes from Lotus Notes and Domino
Accessing documents in a Lotus Notes database
Adding an action to the Lotus Notes right-click menu
Writing temporary text files that email as attachments
Trapping the on-click event of a radio button
Copying a form object using LotusScript
Connecting to a remote DB2 server with LEI

LotusScript
LotusScript agent parses ACL to Microsoft Notepad
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Lotus Notes Domino on Blackberry and mobile devices
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts