def extract_fields(d, fields, delimiter='<STR_LIT:|>'):
rd = {}<EOL>for f in fields:<EOL><INDENT>v = d.get(f, None)<EOL>if isinstance(v, (str, unicode)):<EOL><INDENT>v = v.encode('<STR_LIT:utf8>')<EOL><DEDENT>elif isinstance(v, list):<EOL><INDENT>v = delimiter.join(v)<EOL><DEDENT>rd[f] = v<EOL><DEDENT>return rd<EOL>
get values out of an object ``d`` for saving to a csv