943,683 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 784
  • PHP RSS
Jul 21st, 2009
0

parsing a csv file

Expand Post »
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..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
cali_dotcom is offline Offline
51 posts
since Apr 2008
Jul 21st, 2009
0

Re: parsing a csv file

http://php.net/fgetcsv There's a builtin PHP function
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jul 21st, 2009
0

Re: parsing a csv file

Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
cali_dotcom is offline Offline
51 posts
since Apr 2008
Jul 21st, 2009
0

Re: parsing a csv file

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
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jul 21st, 2009
0

Re: parsing a csv file

[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
Attached Files
File Type: zip strippedouttext.zip (21.2 KB, 24 views)
Last edited by almostbob; Jul 21st, 2009 at 7:49 pm.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: http://www.xyz.com/?id=1 style URL
Next Thread in PHP Forum Timeline: upload file thru php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC