Created
November 4, 2014 15:41
-
-
Save ivanhoe011/8ead939e49d8f2c9dfe0 to your computer and use it in GitHub Desktop.
Split huge csv vertically
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 | |
$split_on_column = 150; // on which column we split | |
$fp = fopen('big.csv', 'r'); // input | |
$f1 = fopen('out1.csv', 'w'); // output1 | |
$f2 = fopen('out2.csv', 'w'); // output2 | |
while ($row = fgetcsv($fp)) { | |
fputcsv($f1, array_slice($row, 0, $split_on_column)); | |
fputcsv($f2, array_slice($row, $split_on_column)); | |
} | |
fclose($fp); | |
fclose($f1); | |
fclose($f2); | |
// END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment