Hi,
I have a CSV file of information, (5 columns) and I want to write a plugin to process the file. I want to-
Read in the file, (done with one of the available code snippets)
Read thro' the file
If the row has valid data (Column 5 has a one in it)
Move to the Person who's Record Id is in Col 2
Create a Citation for Source No 1041 against the <whole record>* for that person (rather than a particular event)
Populate "Where In Source" Field with some Text
below is part of the code for the plugin that is set up to read just the first 3 records in the file to start with. It runs without error but doesn't do what I have described above. Any ideas why not? ( I think I'm not getting the right ptrCite....
--> Load CSV with file with header
local lines,titles = table.loadcsv('C:\\Users\\Ian Mitchell.ianmitcell-PC\\Downloads\\filetablist.csv',true)
for i=1, 3 do
if lines[titles[5]]=="1" then
sName = (lines[titles[1]])
sId = (lines[titles[2]])
iId = tonumber(sId)
sTab = (lines[titles[3]])
sFile = (lines[titles[4]])
sText = "File "..sFile.." Tab "..sTab
ptrIndi = fhNewItemPtr() --> moving to record for individual in file using the ref number
ptrIndi:MoveToRecordById('INDI',iId)
ptrSource=fhNewItemPtr() --> moving to record for the Source "Phyiscal File" which is source number 1041
ptrSource:MoveToRecordById('SOUR',1041)
--> record the citation record for the 1041 Source against the whole record for the individual, (not a particualar event)
ptrCite=fhCreateItem('SOUR',ptrIndi)
ptrField=fhCreateItem('PAGE',ptrCite)
fhSetValueAsText(ptrField,sText)
end
end
* Creating a citation for a source
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Creating a citation for a source
If you check the All tab for the Individuals you will find it has done everything defined by the Plugin script.
The one thing you have not done is link the Citation to the Source record:
fhSetValueAsLink(ptrCite,ptrSource)
The one thing you have not done is link the Citation to the Source record:
fhSetValueAsLink(ptrCite,ptrSource)
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Creating a citation for a source
Thanks a lot, Mike, that worked!!!!