fix for CRM-13207
[civicrm-core.git] / tools / scripts / csv-generator / csv_generator.php
1 <?php
2
3 /**
4 * This file generates sample csv fil for testing large imports.
5 * Run following command: php csv_gen.php
6 * It will generate contacts.csv file with $totalRows contacts
7 */
8 $data = "First Name, Last Name, Email, Street Address 1, Street Address 2, Phone, IM \r\n";
9
10 $totalRows = 80000;
11 $count = 1;
12 while ($count <= $totalRows) {
13 $data .= "first{$count}, last{$count}, email{$count}@email.com, street1{$count}, street2{$count}, 9888909{$count}, im{$count} \r\n";
14 $count++;
15 }
16
17 $filename = 'contacts.csv';
18
19 if (!$handle = fopen($filename, 'w')) {
20 echo "Cannot open file ($filename)";
21 exit;
22 }
23
24 if (fwrite($handle, $data) === FALSE) {
25 echo "Cannot write to file ($filename)";
26 exit;
27 }
28
29 echo "Successfully created csv for $totalRows contacts and wrote to file ($filename)\n\r";
30
31 fclose($handle);
32