re: How to save form data as csv

jdaniels

New Member
Messages
11
Reaction score
0
Points
0
Hi,

I have a webpage that asks participants to fill in answers to questions. At the moment the form gets emailed to me, but it came up as postdata.att or as a text file. I need to get this information into excel.

I want the following to happen: When someone presses submit on the webpage the data entered should save as a csv file, which I can then import excel at a later stage (after Xmas)

Can someone either help or point me in the right direction

Thanks
 

adrenlinerush

New Member
Messages
379
Reaction score
1
Points
0
csv is simply a text format.... it comma delimited file if a comma is in the data then it is in quotes ... if thier is a quotes in the data then two sets of quotes example

data1,"data two, data three", "data four "" more data"

this evaluates to
col 1 data
col 2 data two, data three
col 3 data four " more data
 
Last edited:

jdaniels

New Member
Messages
11
Reaction score
0
Points
0
At the moment my submit script directs the form data to be submitted as an email. I want to get the answers to the various questions into excel with a unique identifier. I have no idea at the moment as to how to do this.

I need a simple solution. Can someone help?
 

adrenlinerush

New Member
Messages
379
Reaction score
1
Points
0
ok what language are you using for cgi.... perl?, php?, python? ruby?

simply the script must do a few things...
accept the cgi post
create a text file in csv format described above
create an email probably using sendmail
attach the csv text file to the email before submitting it to sendmail
Edit:
actually you probably just want to append one file and leave it on the web host until you're ready to look at the data
Edit:
some perl snipit that will do the job

(1) collect the input data

use CGI();
my $form = new CGI();
my %Data;
for($form->param)
{ $Data{$_} = $form->param($_) }


(2) output this data to a file

open (F,'formData.txt') or die "Open failed: $!\n";
for(keys %Data) { print "Data{$_} eq $Data{$_}\n" }
close F or die "Close failed: $!\n";
 
Last edited:

jdaniels

New Member
Messages
11
Reaction score
0
Points
0
Hi,

My webpage is at the following address - http://www.jdaniels.x10hosting.com/
It's a really simple page, but I do not understand what you've said. Not because it is wrong, but because I am new to this and it doesn't make sense to me. I understand the concept but not sure how to create the necessary files. Would it be possible to do this for me? It would have been straight forward as I had a formmail.php script created, but my work server doesn't accept php files. You will find reference in the above link to this, which I need to amend.

Why is life so complicated at times!!!!

Yours

Getting frazzled
 

adrenlinerush

New Member
Messages
379
Reaction score
1
Points
0
I usually don't do work for free...
1) I'm the only computer person in a 50 mil a yr company and I'm pressed for time right now to get this accounting system done by the first of the year
2) i'm a firm believer in give a man a fish feed him for a day teach a man to fish and feed him for life

you should do the research and learn it so when you need another script written you can do it yourself.... what i've given you is a file format to write the text file in and I've given you perl snipits on how to accept cgi post along with how to write text file... you just need to put it together to match your form... google has always been a developers best friend...
 

jdaniels

New Member
Messages
11
Reaction score
0
Points
0
I agree with your sentiments. I work for a ridiculously sized company who for some reason are asking an amateur to do an experts job, whilst paying in gold bullion.

I actually learn't HTML 10yrs ago, but things have moved on since then. I have been on google most of the day trying to sort this out, but will take your feedback and see if I can put it together to work for me.

Thanks anyway
 

HeavyMetalMan

New Member
Messages
13
Reaction score
0
Points
0
I'm having a similar problem, I get the e-mail from the form but can't create, write and append to a CSV file, I have the code from Netobjects. It can't seem to create the .csv file, where should I point it to (which folder)? I have it pointing to a folder with wide open permissions to be able to write.

It goes to this page: http://heavymetalman.x10hosting.com/scripts/FormHandler.php
and get this error:
An error occured. Please contact the site administrator.

Error code: 500
Thank you, I think I'm close but I need a little help!
 

Dannz

New Member
Messages
43
Reaction score
0
Points
0
Python has a module which allows importing and exporting from excel spreadsheets (something like PyExcelarator) which makes doing this really really easy. Also saving to a text file with csv is really easy in Python. You'd have to request the PyExcelarator be installed, otherwise it should be pretty straightforward. I'd use XMLRPC to pass data to the Python script and then it can be outputted to csv, Excel, pdf, doc or whatever you want.
 
Top