Hi,
I am receiving dicts at runtime from reading a csv file, such as:
D = _{a:[1,2,'',4],b:[w,x,y,z]}.
Each list value corresponds to a column in the original csv. Empty atoms are missing values. I would like to replace each missing value with a distinct fresh variable. What is a good way of achieving that ?
My code for acquiring the dict:
:-use_module(library(csv)).
:-use_module(library(clpfd),[transpose/2]).
cdr([_|T],T).
csv_to_dict(File,Tag,Dict):-
csv_read_file(File,[Header|Rows]),
Header=..[row|Names],
maplist(=..,Rows,D),
maplist(cdr,D,Data),
transpose(Data,Columns),
pairs_keys_values(Pairs,Names,Columns),
dict_create(Dict,Tag,Pairs).
Thanks !