EntityUpdateDataCSV
SingleEntityUpdateDataCSV Objects
class SingleEntityUpdateDataCSV(CSVParser.CSVParser)
ApertureDB General CSV Parser for Adding and Updating Properties in an Entity
Update an Entity to the data in the CSV What this means is:
- If it doesn't exist, add it.
- If it exists, update the properties.
This class utilizes 2 conditionals
- normal constraint_ to select the element
- a series of updateif_ to determine if an update is necessary
Conditionals:
updateif>_prop
: updates if the database value greater than csv value
updateif<_prop
: updates if the database value less than csv value
updateif!_prop
: updates if the database value is not equal to csv value
Is backed by a CSV file with the following columns (format optional):
filename
, PROP_NAME_1
, ... PROP_NAME_N
, constraint_PROP1
, format
OR
url
, PROP_NAME_1
, ... PROP_NAME_N
, constraint_PROP1
, format
OR
s3_url
, PROP_NAME_1
, ... PROP_NAME_N
, constraint_PROP1
, format
OR
gs_url
, PROP_NAME_1
, ... PROP_NAME_N
, constraint_PROP1
, format
..
Example CSV file::
filename,id,label,constraint_id,format,dataset_ver,updateif>_dataset_ver,gen_blobsha1_sha /home/user/file1.jpg,321423532,dog,321423532,jpg,2,2, /home/user/file2.jpg,42342522,cat,42342522,png,2,2, ...
Example usage:
data = ImageForceNewestDataCSV("/path/to/ImageData.csv")
loader = ParallelLoader(client)
loader.ingest(data)
In the above example, the constraint_id ensures that an Image with the specified id would be only inserted if it does not already exist in the database.