parsing a csv file

Reply

Join Date: Apr 2008
Posts: 35
Reputation: cali_dotcom is an unknown quantity at this point 
Solved Threads: 0
cali_dotcom cali_dotcom is offline Offline
Light Poster

parsing a csv file

 
0
  #1
Jul 21st, 2009
hi, im not such a php expert and i want to parse a csv file located at http://www.totalbeauty.com/resource/lists. does anyone know how i can do this, what to watch out for, the best way to do this and just general tips for parsing files.
thanks..
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,403
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: parsing a csv file

 
0
  #2
Jul 21st, 2009
http://php.net/fgetcsv There's a builtin PHP function
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 35
Reputation: cali_dotcom is an unknown quantity at this point 
Solved Threads: 0
cali_dotcom cali_dotcom is offline Offline
Light Poster

Re: parsing a csv file

 
0
  #3
Jul 21st, 2009
Originally Posted by ShawnCplus View Post
http://php.net/fgetcsv There's a builtin PHP function
does anyone know how to get the max lenght of any line in the file? the fgetcsv() requires a lenght argument that should ne greater that the longest line in the file.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,403
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: parsing a csv file

 
0
  #4
Jul 21st, 2009
Originally Posted by cali_dotcom View Post
does anyone know how to get the max lenght of any line in the file? the fgetcsv() requires a lenght argument that should ne greater that the longest line in the file.
Unless you're using PHP4 you don't need it, if the PHP document shows an argument in [] then it is optional
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,350
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: parsing a csv file

 
0
  #5
Jul 21st, 2009
[quote-php 5.04 manual]fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read.
. . . . .
length
Must be greater than the longest line (in characters) to be found in the CSV file (allowing for trailing line-end characters). It became optional in PHP 5. Omitting this parameter (or setting it to 0 in PHP 5.0.4 and later) the maximum line length is not limited, which is slightly slower.
. . . . .[/quote] no longer really necessary, if your host is running php5

its not a very well formed file, only 3 lines, a list of brandnames, semi-colon separated no quotes
Last edited by almostbob; Jul 21st, 2009 at 7:49 pm.
Attached Files
File Type: zip strippedouttext.zip (21.2 KB, 2 views)
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC