Created
October 21, 2013 15:19
-
-
Save clouddueling/7085656 to your computer and use it in GitHub Desktop.
csv splitting controller
This file contains hidden or 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 | |
| class Test_Controller extends Base_Controller | |
| { | |
| public function get_index() | |
| { | |
| try { | |
| $s = extend(array( | |
| ), sr()); | |
| $new_csv = array(); | |
| $rows = Parse::fromCSVFile("storage/work/sheet.csv"); | |
| foreach ($rows as $row) { | |
| $name = explode(', ', $row[1]); | |
| $row[] = isset($name[0]) ? $name[0] : ''; | |
| $row[] = isset($name[1]) ? $name[1] : ''; | |
| $new_csv[] = $row; | |
| } | |
| file_put_contents("storage/work/new.csv", Parse::toCSV($new_csv)); | |
| return json(array( | |
| )); | |
| } catch(Exception $e) { | |
| return Report::log($e->getMessage()); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment