Created
September 24, 2012 04:00
-
-
Save dpmckenzie/3774129 to your computer and use it in GitHub Desktop.
My not-quite-functioning CSV-modifying PHP file--not functioning even after class help. If anyone has ideas, do tell. I meanwhile have learned a faster way to do this. :)
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
<?php | |
ini_set("auto_detect_line_endings", true); | |
$fileName = 'cases.csv'; | |
// set function for opening file | |
$file = fopen($fileName, "r+") or die("can't open file"); | |
// recognize file as csv, get it to loop | |
while(($data = fgetcsv($file, 1000, ',')) !== FALSE) { | |
// set the second column to old date | |
$old_date = $data[1]; | |
// switch the order | |
$new_date = explode('/', $old_date); | |
$date = $new_date[2].'-'.$new_date[0].'-'.$new_date[1]; | |
// set the second column to new date | |
$data[1] = $date; | |
fputcsv($file, $data); | |
} | |
// close csv file | |
fclose($file); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment