Well, it's like a normal HikaShop CSV. If you create such product on your backend and you click on the export button of the products listing, you'll get a CSV with the example you want.
$csv = "product_name,product_code,product_parent_id,price_value,categories,color,weight\r\n".
"paint,p001,,1,category name,red,1kg\r\n".
",p001r1,p001,1,,red,1kg\r\n".
",p001r5,p001,5,,red,5kg\r\n".
",p001r25,p001,25,,red,25kg\r\n".
",p001b1,p001,1,,blue,1kg\r\n".
",p001b5,p001,5,,blue,5kg\r\n".
",p001b25,p001,25,,blue,25kg\r\n";
$importHelper = hikashop_get('helper.import');
$importHelper->handleContent($csv);
And I don't understand your last questions. Characteristics don't have "codes". They have values, aliases and aliases for their values, no codes. If you're talking about the aliases, then yes, you can use the alias of the values instead of the values.