Parsing CSV in to a table?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

User avatar
atw
New php-forum User
New php-forum User
Posts: 18
Joined: Wed Nov 06, 2002 8:03 am
Location: England

Parsing CSV in to a table?

Postby atw » Wed Nov 06, 2002 11:42 am

Does anyone have a simple PHP script to read a CSV file and parse it into a table.

Thanks for your time...

atw

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Thu Nov 07, 2002 5:20 am

$csvfile=file("file.txt");

for ($i=0; $i < count($csvfile); $i++ )
{
//this action will explode values in the csv file
$data=explode(";" , $csvfile[$i]);

//you can do enything you want with values thay are look like that $data[0] $data[3] etc.

}

User avatar
atw
New php-forum User
New php-forum User
Posts: 18
Joined: Wed Nov 06, 2002 8:03 am
Location: England

Postby atw » Thu Nov 07, 2002 6:31 am

Excellent, thank you...

Just one question,
$data=explode(";" , $csvfile[$i]);
does the ";" denote (signify) the delimiter character?


Thanks for your time :D

PHP Guru

Postby PHP Guru » Thu Nov 07, 2002 9:35 am

yes

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Thu Nov 07, 2002 10:03 am

2PHP Guru
Jay, why you register new account ?

PHP Guru

Postby PHP Guru » Thu Nov 07, 2002 2:52 pm

You got a problem with that? No-one said not to come back! And at the end of the day, I know more PHP than all you guys put together. You even had to copy my php-forums.com logo!!

User avatar
atw
New php-forum User
New php-forum User
Posts: 18
Joined: Wed Nov 06, 2002 8:03 am
Location: England

Postby atw » Thu Nov 07, 2002 3:46 pm

Calm down, chill-out.

Thank you both for the help, it worked beautifully.

Checkout: http://www.atwright.com/phpxml/csvtest2.php

(The table coding needs a little tweeking but it'll work as a temporary measure until I get the MySQL DB up and running :wink:

Thanks again...

PS. Why is the forum moving???

PHP Guru

Postby PHP Guru » Thu Nov 07, 2002 4:04 pm

It's not, DoppyNL and myself have moved to provide a better service with more features and enhancements (I can't say more 'cos my ideas will be stolen, like my logo)

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Fri Nov 08, 2002 4:30 am

I have no problem with this!
Chill out man! I just ask you...
This is your own buisness where is in NET you are live...

User avatar
admin
Site Admin
Site Admin
Posts: 123
Joined: Wed Apr 17, 2002 7:49 am
Location: Rome, Italy
Contact:

Postby admin » Fri Nov 08, 2002 4:58 am

PHP Guru wrote:It's not, DoppyNL and myself have moved to provide a better service with more features and enhancements (I can't say more 'cos my ideas will be stolen, like my logo)


1) there are tons of php site which use <? ?> in their logo , this is an example , http://www.phpcomplete.com .

2) you have copied the idea and domain name and you attempted to move all registered users from here to there taking advantage of your moderator powers and hoping that I was sleeping . and you have still the courage to speak ....

Your forum is better and you are a php guru ; but please don't disturb us again , here we want speak of php . If you want promote your site you can use search engines .

If you want stay here , you can stay ,but you cannot spam in the way Jay and Doppy was doing . Here you can speak of php nothing else.

Thank you


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron