Buy Now
Sign in

Writing to CSV file

joachimliedtke , November 17 2017
Hi there,

although reading everything? on this matter, I am not able to manage to write something to CSV. What I want is, that the content of a submitted form is written to a CSV file (not the whole table).

So far working: Content of the form is saved to the Joomla-database. Path for the CSV is set and the file are generated with a unique name.

Not working: Reading the database table and writing the result to the CSV file.

There are so many fields I have to fill in the backend, but I don't know what to type in.

Part Read Data:
Model name? The model name from the Save Data part? In my case Data6.
Database table is correctly selected.
Where conditions? What do I have to insert here?
Order fields? I think I can leave it blank, because I only the result for the currently submitted form.
Data settings
Selecty type? Which is the correct one?
Paging for multiple result? Deactivated?
Page limit? One I assume.
Offset? Needed?
Fields to retrieve? What do I have to fill in?
This is an extra fields list? Checked?
Group fields? Not needed I assume.
Special fields? Not needed I assume.

CSV part
Data provider? The model name?
Action? In my case only Store.
Delimiter: Set to comma.
Titles? What do I have to fill in?
Disable header titles? Enabled or disabled?
File name is correctly set and working.
Path for saving is correctly set and working.

Pretty much I know, but I am completely lost and my English is not the best. A helping hand would be nice, best with screenshots

Hi joachimliedtke ,

Saving the form content to a CSV file is usually not very helpful as you get a CSV file with just one record in it. It may be simpler to save the data to a Google Spreadsheet where each record will add a new row.

If you do want to save a single record, then you can ignore the table setting in the CSV Export action and use the Data Path entry instead to identify a sub-array of the $form->data array to be saved. I think that you can then ignore all the other settings as they ae intended for use when you want to export multiple records from a database table.

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
Hi Bob,

thanks for your answer. I managed to get it work PARTIALLY. All the values are written to the database, but the output to csv is not as expected.

My form has 16 fields, but only the first 6 and the 12th is written properly. The rest is empty or complete nonsense. For example one value is changed from "123456" to "446546" and the textarea changes from "Ich muss mit meinem Hamster zur PZR" into "erte".

Any idea how to fix.

Perhaps some bugs were fixed in the meantime? I am still using 6.0.12

Works with 6.0.14!

Reading only one record is working with CSV. I had to set "Page limit" to "1" and sort to "aid/desc", BUT the order field is not independent from the rest. You also have to enter "DataXY.aid" in "Fields to retrieve". So the "aid" will be also written to CSV, but I can live with that.

Thanks for your support!