Write Out Field Values To A Csv File

This Content Component encountered an error
This little workhorse takes a view of your choice, an array of field names, and
a filename, then gets the value of those items and writes them to a file in CSV
format. If nothing is found in the view, it returns false.
Enjoy!
Function WriteValuesToFile(viewTarget As NotesView, varFieldNames As
Variant,strFileName As String) As Integer
Dim intFileNum As Integer
Dim intArraySubscript As Integer
Dim vecViewTarget As NotesViewEntryCollection
Dim ventViewTarget As NotesViewEntry
Dim docViewTarget As NotesDocument
Dim strFieldName As String
Const Quote = {"}
Const Delim = {,}
Const EndLine = {;}

Set vecViewTarget = viewTarget.AllEntries

If vecViewTarget.count < 1 Then 'Check for values to retrieve before opening a
file handle

WriteValuesToFile = False
Exit Function

Else
WriteValuesToFile = True
End If

intFileNum = Freefile()

Open strFileName For Output As #intFileNum

Set ventViewTarget = vecViewTarget.GetFirstEntry 'Get 1st entry in view

Do While Not ( ventViewTarget Is Nothing) ' for all the documents in the
view, print out the desired field values to the file
Set docViewTarget = ventViewTarget.Document
strDocRecord = ""
For intArraySubscript = 0 To Ubound(varFieldNames)

strFieldName = varFieldNames(intArraySubscript)

Set itmNeeded = docViewTarget.GetFirstItem(strFieldName)

If strDocRecord = "" Then

strDocRecord = Quote & itmNeeded.text & Quote
Else


strDocRecord =strDocRecord & Delim & Quote & itmNeeded.text & Quote

End If


Next intArraySubscript
strDocRecord =strDocRecord & EndLine 'Here is the whole delimited string to
go on a line in the file
Print #intFileNum, strDocRecord


Set ventViewTarget = vecViewTarget.GetNextEntry(ventViewTarget)
Loop


Close #fileNumInt

End Function
This was first published in November 2000

Dig deeper on Domino Resources - Part 5

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close