is there a way to change the path of...

User 120260 Photo


Registered User
8 posts

Eric Rohloff wrote:
I think have a solution. Do all of your forms have the same amount of inputs?

all forms are identical, same fields etc...
Is that your question Eric?
User 187934 Photo


Senior Advisor
20,271 posts

Yup, Ok I have a partial solution. This code will put all your csv's from several form storage folder into a single csv. The only thing I don't have worked out yet is grabbing only one set of column headers so the code won't print those out.
<?php
$files_to_merge = array(
"/csv1/storage/csv/form-results.csv", // form 1
"/csv2/storage/csv/form-results.csv", // form 2
"/csv3/storage/csv/form-results.csv" // form 3
);
$ftm = fopen("merged.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);
echo($file . "-". $count . "\n");
endforeach;
fclose($ftm);

?>

The location of this code would be at the same level as any form page that you use the form builder embed script on.
The script will write a merged.cvs of all the csv's in the list to the same level as the script. Alter the csv1, csv2, csv3 to your desired forms. Add more but be aware that the last one in the list won't have a , at the end but the rest will.
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
User 120260 Photo


Registered User
8 posts

Fantastic !

One more question, on where to place the code exactly?
If I understand correctly then...I would paste this code inside the embed code produced by the software..
Does in matter where inside the file I paste it after i edit it...
does it replace something or can it be pasted atop?

Sorry for all the questions..you have been such a help..
User 187934 Photo


Senior Advisor
20,271 posts

The code the way it stands would go in the same directory as the myformname.php.
What I did for testing was was create 3 forms. I then exported them all to the same directory. I ended up with csv1_exported, csv2_exported, csv3_exported and the merge_csv.php script all in the same folder. I then removed the _exported from each of the folder names.
The merge_csv.php script looked like this.
<?php
$files_to_merge = array(
"/csv1/csv1/storage/csv/form-results.csv", // form 1
"/csv2/csv2/storage/csv/form-results.csv", // form 2
"/csv3/csv3/storage/csv/form-results.csv" // form 3
);
$ftm = fopen("merged.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);
echo($file . "-". $count . "\n");
endforeach;
fclose($ftm);

?>

As you can see the script is looking one level deeper then the one I posted earlier. It all depends on what level of organization your looking for. I only do this to keep all the files for my forms separate. I'll then alter the embed script that the form builder generates to also look one level deeper because of the _exported name change.
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
User 464893 Photo


Ambassador
1,611 posts

Your PHP is getting good Eric. Yes! still kicking. On a new trialed chem, no hair, whiskers and very weak but have passed the original life expectancy of 3 months by an extra 6 months now. Still no cure though as yet.
The Guy from OZ


User 187934 Photo


Senior Advisor
20,271 posts

Prism, Thanks for posting back. I'm very pleased to see you back here in the regular forum. Did I say regular forum?:lol:
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

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.