Forum Moderators: coopster

Message Too Old, No Replies

export text as a csv file

export text as a csv file

         

vivek avasthi

7:19 am on Jun 27, 2006 (gmt 0)

10+ Year Member



i have some text in a textarea ...
like this

E-mail;Name;LastName;Company;Address1;Address2;City;State;Postcode;Telephone;Date
vkavasthi@example.com;vivek;;;;;;;;;2006-06-01
vbn@example.com;;;;;;;;;;2006-06-01
ad@example.com;;;;;;;;;;2006-06-03
ac@example.com;;;;;;;;;;2006-06-03
vivek@example.com;;;;;;;;;;2006-06-12
VC@EXAMPLE.COM;;;;;;;;;;2006-06-02
vkasd@example.com;;;;;;;;;;2006-06-02
asd@example.com;vivek;avasthi;Webwalas;J-71 A;;Delhi;Laxmi Nagar;100092;9811521009;2006-06-03
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivek@example.com;;;;;;;;;;2006-06-12
vivekavasthi@example.com;;;;;;;;;;2006-06-12
hai@yahoo.com;dasdfs;dfSADF;sdfsdf;sdfsdf;;fsdf;fsdf;;sdfsd;2006-06-21

i want to export these text as a CSV file on my coputer... How can i do this..

[edited by: jatar_k at 8:47 am (utc) on June 27, 2006]

[edited by: coopster at 1:30 am (utc) on June 28, 2006]
[edit reason] examplified [/edit]

the_nerd

9:24 am on Jun 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



either: cut - paste - save (using some editor)

or: (if you have access to php or something else server-side)

when the form containing your textarea is executed, save the text to a file on the server (tmp-name) and show a download-link to that file on the next page.

eelixduppy

5:16 pm on Jun 27, 2006 (gmt 0)



I would first replace all of the '\r\n' characters in the textarea with ',\n' or something equivalent.

$text = [url=http://us2.php.net/manual/en/function.str-replace.php]str_replace[/url]("\r\n",",\n",$_POST["text"]);

Then you can write this to a file using fwrite [us2.php.net].

Good luck!