Creating a citation for a source
Posted: 20 Dec 2017 19:42
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
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