Last active
March 19, 2018 19:40
-
-
Save rivaadara111/c880ab6a3f0e144395bd50eb233407ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//a simple script to convert a csv to xml | |
<?php | |
$csvfile = 'DispensariesNEW.csv'; | |
$xmlfile = 'dispensariesoutput.xml'; | |
// Open csv to read as array | |
$csv = array_map('str_getcsv', file($csvfile)); | |
array_walk($csv, function(&$a) use ($csv) { | |
$a = array_combine($csv[0], $a); | |
}); | |
array_shift($csv); //remove column header | |
$dispensaries = $csv; ?> | |
<?php echo '<?xml version="1.0" encoding="utf-8" ?>'; ?> | |
<markers> | |
<?php foreach ($dispensaries as $dispensary) : | |
$name = $dispensary['Name']; | |
$status = $dispensary['Status']; | |
$address = $dispensary['Address']; | |
$neighbourhood = $dispensary['Neighbourhood']; | |
$city = $dispensary['City']; | |
$postal_code = $dispensary['Postal']; | |
$phone = $dispensary['Phone']; | |
$website = $dispensary['Website']; | |
$long = $dispensary['Long']; | |
$lat = $dispensary['Lat']; | |
$image = $dispensary['Image']; | |
$image_credit = $dispensary['ImCredit']; | |
$image_credit_link = $dispensary['ImCrLink']; | |
$info = '<div class="maps-info-window"><div class="info-wrap">'; | |
$info .= '<div class="info-window-rest"><h2 class="sans-pro"><a href="' . $website . '">' . $name .'</a></h2>'; | |
if(!empty($neighbourhood)){ | |
$info .= '<p class="hood">' . $neighbourhood . '</p>'; | |
} | |
$info .= '<div class="info-window-wins info-window-addy"><p>' . $address . '</p><p>' . $city . '</p><p>' . $postal_code . '</p><p>' . $phone . '</p></div></div>'; | |
if (!empty($image)) { | |
$info .= '<div class="info-window-img twitterpic-for-' . $name . '"><img width="120" height="120" src="'. $image . '" /><p class="image-credit sans-pro"><a href="' . $image_credit_link . '"><span>Photo credit:</span> ' . $image_credit .'</a></p></div></div>'; | |
$info .= '<p class="info-window-summary sans-pro">'. $status . '</p>'; | |
$info .= '</div>'; | |
} | |
else { | |
$info .= '<p class="info-window-summary sans-pro">'. $status . '</p>'; | |
$info .= '</div>'; | |
} | |
?> | |
<marker name="<?php echo $name; ?>" status="<?php echo $status; ?>" lat="<?php echo $lat; ?>" long="<?php echo $long; ?>" info="<?php echo htmlspecialchars($info);?>" hood="<?php echo $neighbourhood;?>" /> | |
<?php endforeach; ?> | |
</markers> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment