/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import os import csv data = csv.reader(open('source.csv')) fields = data.next() output = '<?php %s$countries = array(%s' % (os.linesep, os.linesep) for row in data: if row[0]: output += '%s"%s%s" => array("country" => "%s", "email" => "%s"),' \ % (os.linesep, row[1], row[4], row[0], row[5]) output = output[:-1] + '); ?>' f = open('/path/to/destination.php', 'w') f.write(output) f.close()
Comments
