Hello everyone,

I have run into an issue that I am not sure the best way to resolve.

I am reading in a file (for an MLS data import) one line at a time, and
then storing that line into a database. Here is what I am doing (with
error checking and unrelated processing removed for brevity):

==== Code Start ====
$fileref=fopen($FILENAME, "r");
$header_line=fgets($fileref);

while (!feof($fileref)):
  // Read a single line from the file
  $mls_line=addslashes(fgets($fileref))

  // Continue processing to add to DB
endwhile;
==== Code End ====

Now, my problems and questions are these:

First, it appears that the above fgets line defaults to stopping after
1024 bytes, instead of the EOL. This is a problem, as some of the lines
are over 2500 bytes long

I know that I can do fgets($fileref,4096) to read the long lines, but is
there a problem with doing this that I am not seeing?

I need to read the lines in one at a time, break the line up into its 83
fields, store that in the database, and then repeat until I am at EOF.
There are times with this could be 30000+ lines to read in and parse.

Is there a better way to do this? Are there any drawbacks to increasing
the read length for fgets by so much?
--
Doug

Registered Linux User #285548 (http://counter.li.org)
----------------------------------------
Random Thought:
I am NOT a nut....



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to