"Using Python to Extract Data from NSF" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "Using Python to Extract Data from NSF" answered properly. Developers are finding an appropriate answer about Using Python to Extract Data from NSF related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like Using Python to Extract Data from NSF. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on Using Python to Extract Data from NSF.
Using Python to Extract Data from NSF
import win32com.client
import csv # imports the csv module
import sys # imports the sys module
import re
notesServer = "NotesServer/Certifier"
notesFile = "NotesFolder\NotesDatabase.nsf"
notesPass = "NotesPassword"
#Connect to notes database on server
notesSession = win32com.client.Dispatch('Lotus.NotesSession')
notesSession.Initialize(notesPass)
notesDatabase = notesSession.GetDatabase(notesServer,notesFile)
notesView = '(All Documents)'
notesView = notesDatabase.GetView(notesView)
notesDoc = notesView.GetFirstDocument()
#Code block used from another blog.See resources section
def makeDocumentGenerator(folderName):
# Get folder
folder = notesDatabase.GetView(folderName)
if not folder:
raise Exception('Folder "%s" not found' % folderName)
# Get the first document
document = folder.GetFirstDocument()
# If the document exists,
while document:
# Yield it
yield document
# Get the next document
document = folder.GetNextDocument(document)
#Loop through documents extracting data from listed fields and view.
for document in makeDocumentGenerator(notesView):
try:
crm_iencompany = document.GetItemValue('IENCompany')[0].encode('utf-8').strip()
docID = str(document.UniversalID.strip()) #Get the document ID to make filename unique
crm_principle = document.GetItemValue('Principle')[0].encode('utf-8').strip()
crm_iensubject = document.GetItemValue('IENSubject')[0].encode('utf-8').strip()
crm_ienviewphones = document.GetItemValue('IENVIEWPHONES')[0].encode('utf-8').strip()
crm_ienviewfullname = document.GetItemValue('IENVIEWFULLNAME')[0].encode('utf-8').strip()
crm_ienviewaddress = document.GetItemValue('IENVIEWADDRESS')[0].encode('utf-8').strip()
crm_iensalesrep = document.GetItemValue('IENSalesRep')[0].encode('utf-8').strip()
crm_entersendto = document.GetItemValue('EnterSendTo')[0].encode('utf-8').strip()
crm_entercopyto = document.GetItemValue('EnterCopyTo')[0].encode('utf-8').strip()
crm_from = document.GetItemValue('From')[0].encode('utf-8').strip()
crm_body = document.GetItemValue('Body')[0].encode('utf-8').strip()
#Remove any characters from filename which are not valid.
fileName = crm_iencompany + "-" + docID + ".txt"
fileName = fileName.replace("/"," ")
fileName = fileName.replace("\\"," ")
fileName = fileName.replace(":"," ")
fileName = fileName.replace("\r"," ")
fileName = fileName.replace("\n"," ")
fileName = fileName.rstrip('\r\n')
fileName = fileName.rstrip('\n\r')
fileName = fileName.rstrip('\n')
fileName = fileName.rstrip('\r')
cleaned_up_filename = re.sub(r'[/\\:*?"<>|]', '', fileName)
#Write to txt file.
with open(cleaned_up_filename, 'w') as f:
f.write("iencompany:" + crm_iencompany + "," + "\n")
f.write("principle:" + crm_principle + "," + "\n")
f.write("ienviewphones:" + crm_ienviewphones + "," + "\n")
f.write("ienviewfullname:" + crm_ienviewfullname + "," + "\n")
f.write("ienviewaddress:" + crm_ienviewaddress + "," + "\n")
f.write("iensalesrep:" + crm_iensalesrep + "," + "\n")
f.write("entersendto:" + crm_entersendto + "," + "\n")
f.write("entercopyto:" + crm_entercopyto + "," + "\n")
f.write("from:" + crm_from + "," + "\n")
f.write("subject:" + crm_iensubject + "," + "\n")
f.write("body:" + crm_body + "," + "\n")
except:
print document
pass
Source: markljones.info
All those coders who are working on the Whatever based application and are stuck on Using Python to Extract Data from NSF can get a collection of related answers to their query. Programmers need to enter their query on Using Python to Extract Data from NSF related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Using Python to Extract Data from NSF for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of Using Python to Extract Data from NSF while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "Using Python to Extract Data from NSF". Visit this developer's friendly online web community, CodeProZone, and get your queries like Using Python to Extract Data from NSF resolved professionally and stay updated to the latest Whatever updates.