Very cool. Thanks, gonna try to get on that today.
Hmm, getting an empty merged.csv, multiple attempts. I echoed throughout the script, and it's stopping at the 'while'.
Manually set permissions to 777 just to take that out of the equation. Also changed
$fh = fopen("csv/" .$file, "r");
to
$fh = fopen($file, "r");
... the "csv/". isn't necessary, is it, since the $file full path is already there? (I'm a php doof, so... but, same result either way.)
The files in the array are listed as:
"/Bid1a/storage/csv/BID.csv"
with your script in BidMerge.php, which is at same level as the Bid1a folder.
The echo result from running the script:without all my extra echoes:
/Bid1a/storage/csv/BID.csv- /Bid1b/storage/csv/BID.csv- ...
Manually set permissions to 777 just to take that out of the equation. Also changed
$fh = fopen("csv/" .$file, "r");
to
$fh = fopen($file, "r");
... the "csv/". isn't necessary, is it, since the $file full path is already there? (I'm a php doof, so... but, same result either way.)
The files in the array are listed as:
"/Bid1a/storage/csv/BID.csv"
with your script in BidMerge.php, which is at same level as the Bid1a folder.
The echo result from running the script:without all my extra echoes:
/Bid1a/storage/csv/BID.csv- /Bid1b/storage/csv/BID.csv- ...
O, and I changed
echo($file . "-". $count . "\n");
to
echo($file . "-". count($files_to_merge) . "<br />");
Resulting in
/Bid1a/storage/csv/BID.csv-9
/Bid1b/storage/csv/BID.csv-9
... (there are a total of 9 files)
echo($file . "-". $count . "\n");
to
echo($file . "-". count($files_to_merge) . "<br />");
Resulting in
/Bid1a/storage/csv/BID.csv-9
/Bid1b/storage/csv/BID.csv-9
... (there are a total of 9 files)
A little update:
I can pass a parameter into the form and set a wfb field to the value (using www.blah.com/form.php?12345 as the URL sent to the user).
I can pass that same parameter to each of the subsequent forms, so all 9 have a common identifier (without depending on the user to, for that matter, even spell their name the same for each form).
Thanks to Eric, I can combine all 9 CSVs into a single file. I had to remove the 'while', but am getting my file.
Going the simple route and using a Windows Network Location, I have a desktop link to my CSV directory.
All that's missing is being able to specify the name of the CSV, to simply set the name of the file to be the same as the passed parameter.
I can pass a parameter into the form and set a wfb field to the value (using www.blah.com/form.php?12345 as the URL sent to the user).
I can pass that same parameter to each of the subsequent forms, so all 9 have a common identifier (without depending on the user to, for that matter, even spell their name the same for each form).
Thanks to Eric, I can combine all 9 CSVs into a single file. I had to remove the 'while', but am getting my file.
Going the simple route and using a Windows Network Location, I have a desktop link to my CSV directory.
All that's missing is being able to specify the name of the CSV, to simply set the name of the file to be the same as the passed parameter.
Can you post your entire code now so I know what your working with?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Give this a try. Worked for me.
<?php
if (isset($_GET['var_name'])) { //adjust the var_name to your url variable
$csv_name = $_GET['var_name'];
$files_to_merge = array(
"/csv1/csv1/storage/csv/form-results.csv", "/csv2/csv2/storage/csv/form-results.csv", "/csv3/csv3/storage/csv/form-results.csv"
);
$ftm = fopen($csv_name.".csv","w+");
foreach ($files_to_merge as $file):
$fh = fopen("csv/" .$file, "r");
$line = false;
while (($data = fgetcsv($fh,8192,",")) != FALSE){
if (!$line){
$line = TRUE;
} else {
fputcsv($ftm,$data,",");
}
}
fclose($fh);
endforeach;
fclose($ftm);
}
?>
if (isset($_GET['var_name'])) { //adjust the var_name to your url variable
$csv_name = $_GET['var_name'];
$files_to_merge = array(
"/csv1/csv1/storage/csv/form-results.csv", "/csv2/csv2/storage/csv/form-results.csv", "/csv3/csv3/storage/csv/form-results.csv"
);
$ftm = fopen($csv_name.".csv","w+");
foreach ($files_to_merge as $file):
$fh = fopen("csv/" .$file, "r");
$line = false;
while (($data = fgetcsv($fh,8192,",")) != FALSE){
if (!$line){
$line = TRUE;
} else {
fputcsv($ftm,$data,",");
}
}
fclose($fh);
endforeach;
fclose($ftm);
}
?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Hey Eric! I'll take a look at that code when I can. Here's what I'm using -- this works, and gives me two lines per CSV, so I get
Line1: CSV1 IDs
Line2: CSV1 Values
Line3: CSV2 IDs
Line4: CSV2 Values
Etc through Line 18 of the merged CSV.
<?php
$bidid= $_SERVER['QUERY_STRING'];
$csv1 = file('b1a/storage/csv/BID.csv');
$csv2 = file('b1b/storage/csv/BID.csv');
$csv3 = file('b1c/storage/csv/BID.csv');
$csv4 = file('b1d/storage/csv/BID.csv');
$csv5 = file('b2a/storage/csv/BID.csv');
$csv6 = file('b2b/storage/csv/BID.csv');
$csv7 = file('b2c/storage/csv/BID.csv');
$csv8 = file('b2d/storage/csv/BID.csv');
$csv9 = file('b3/storage/csv/BID.csv');
$lines = max(count($csv1), count($csv2), count($csv3), count($csv4), count($csv5), count($csv6), count($csv7), count($csv8), count($csv9));
$finalcsv = array();
if(isset($csv1[0])) $finalcsv[] = $csv1[0];
if(isset($csv1[1])) $finalcsv[] = $csv1[1];
if(isset($csv2[0])) $finalcsv[] = $csv2[0];
if(isset($csv2[1])) $finalcsv[] = $csv2[1];
if(isset($csv3[0])) $finalcsv[] = $csv3[0];
if(isset($csv3[1])) $finalcsv[] = $csv3[1];
if(isset($csv4[0])) $finalcsv[] = $csv4[0];
if(isset($csv4[1])) $finalcsv[] = $csv4[1];
if(isset($csv5[0])) $finalcsv[] = $csv5[0];
if(isset($csv5[1])) $finalcsv[] = $csv5[1];
if(isset($csv6[0])) $finalcsv[] = $csv6[0];
if(isset($csv6[1])) $finalcsv[] = $csv6[1];
if(isset($csv7[0])) $finalcsv[] = $csv7[0];
if(isset($csv7[1])) $finalcsv[] = $csv7[1];
if(isset($csv8[0])) $finalcsv[] = $csv8[0];
if(isset($csv8[1])) $finalcsv[] = $csv8[1];
if(isset($csv9[0])) $finalcsv[] = $csv9[0];
if(isset($csv9[1])) $finalcsv[] = $csv9[1];
file_put_contents('CSV/final_data.csv', implode("", $finalcsv));
?>
Line1: CSV1 IDs
Line2: CSV1 Values
Line3: CSV2 IDs
Line4: CSV2 Values
Etc through Line 18 of the merged CSV.
<?php
$bidid= $_SERVER['QUERY_STRING'];
$csv1 = file('b1a/storage/csv/BID.csv');
$csv2 = file('b1b/storage/csv/BID.csv');
$csv3 = file('b1c/storage/csv/BID.csv');
$csv4 = file('b1d/storage/csv/BID.csv');
$csv5 = file('b2a/storage/csv/BID.csv');
$csv6 = file('b2b/storage/csv/BID.csv');
$csv7 = file('b2c/storage/csv/BID.csv');
$csv8 = file('b2d/storage/csv/BID.csv');
$csv9 = file('b3/storage/csv/BID.csv');
$lines = max(count($csv1), count($csv2), count($csv3), count($csv4), count($csv5), count($csv6), count($csv7), count($csv8), count($csv9));
$finalcsv = array();
if(isset($csv1[0])) $finalcsv[] = $csv1[0];
if(isset($csv1[1])) $finalcsv[] = $csv1[1];
if(isset($csv2[0])) $finalcsv[] = $csv2[0];
if(isset($csv2[1])) $finalcsv[] = $csv2[1];
if(isset($csv3[0])) $finalcsv[] = $csv3[0];
if(isset($csv3[1])) $finalcsv[] = $csv3[1];
if(isset($csv4[0])) $finalcsv[] = $csv4[0];
if(isset($csv4[1])) $finalcsv[] = $csv4[1];
if(isset($csv5[0])) $finalcsv[] = $csv5[0];
if(isset($csv5[1])) $finalcsv[] = $csv5[1];
if(isset($csv6[0])) $finalcsv[] = $csv6[0];
if(isset($csv6[1])) $finalcsv[] = $csv6[1];
if(isset($csv7[0])) $finalcsv[] = $csv7[0];
if(isset($csv7[1])) $finalcsv[] = $csv7[1];
if(isset($csv8[0])) $finalcsv[] = $csv8[0];
if(isset($csv8[1])) $finalcsv[] = $csv8[1];
if(isset($csv9[0])) $finalcsv[] = $csv9[0];
if(isset($csv9[1])) $finalcsv[] = $csv9[1];
file_put_contents('CSV/final_data.csv', implode("", $finalcsv));
?>
And here's a link to the test form that receives/passes the query string (sorry, fb too big to attach).
http://sumpterconstructionllc.com/CC/TEST1.php?12321
http://sumpterconstructionllc.com/CC/TEST1.php?12321
OK, I'll wait until you give it a try then if we getting it working I want to make an example version of the code for others to possibly use.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Correction to the above code... And for my purposes (always known location and number of files), this works. I'll post a fix to naming the CSV and incorporating that name if/when it happens.
...
$csv1 = file('b1a/storage/csv/BID.csv');
$csv2 = file('b1b/storage/csv/BID.csv');
$csv3 = file('b1c/storage/csv/BID.csv');
$csv4 = file('b1d/storage/csv/BID.csv');
$csv5 = file('b2a/storage/csv/BID.csv');
$csv6 = file('b2b/storage/csv/BID.csv');
$csv7 = file('b2c/storage/csv/BID.csv');
$csv8 = file('b2d/storage/csv/BID.csv');
$csv9 = file('b3/storage/csv/BID.csv');
...
...
$csv1 = file('b1a/storage/csv/BID.csv');
$csv2 = file('b1b/storage/csv/BID.csv');
$csv3 = file('b1c/storage/csv/BID.csv');
$csv4 = file('b1d/storage/csv/BID.csv');
$csv5 = file('b2a/storage/csv/BID.csv');
$csv6 = file('b2b/storage/csv/BID.csv');
$csv7 = file('b2c/storage/csv/BID.csv');
$csv8 = file('b2d/storage/csv/BID.csv');
$csv9 = file('b3/storage/csv/BID.csv');
...
Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.