Re: [PHP] fgets function for very large files

2009-05-25 Thread shahrzad khorrami
in the following loop: $row = 1; while (($line = fgets($handle, 1024)) !== FALSE ) { $line = str_replace(SEPARATOR, ",", $line); $data = explode(",", $line); $row++; } How put 1000 by 1000 lines of csv file to new ones? and you know I think this works slow

Re: [PHP] fgets function for very large files

2009-05-24 Thread Lars Torben Wilson
2009/5/24 shahrzad khorrami : > :-o > I want to divide this large csv file with programming to small one! If you're on *nix: % man split Regards, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] fgets function for very large files

2009-05-24 Thread Nathan Rixham
shahrzad khorrami wrote: :-o I want to divide this large csv file with programming to small one! 1: http://php.net/fgetcsv 2: if( ($row % 1) == 0 ) { 3: http://php.net/fputcsv csv split in to multiple csv's of 10k rows each -- PHP General Mailing List (http://www.php.net/) To unsubscribe

Re: [PHP] fgets function for very large files

2009-05-24 Thread shahrzad khorrami
:-o I want to divide this large csv file with programming to small one!

Re: [PHP] fgets function for very large files

2009-05-24 Thread kranthi
1. open that in a text editor 2. copy a few lines 3. create a new text file 4. paste the copied lines 5. save with the extension .csv but i doubt this process works i faced exactly same problem few months back and i found http://www.tech-recipes.com/rx/2345/import_csv_file_directly_into_mysql/ to

Re: [PHP] fgets function for very large files

2009-05-24 Thread shahrzad khorrami
How to divide a large csv file to small ones? Thanks, Shahrzad

Re: [PHP] fgets function for very large files

2009-05-23 Thread kranthi
i accept the fact that PMA is full of security holes, and it should not be used on production server. but it does not mean that we can never use it on a development server probably you may have a bit of trouble while moving from development server to production server. but u can always export y

Re: [PHP] fgets function for very large files

2009-05-23 Thread Ashley Sheridan
On Sat, 2009-05-23 at 02:59 -0400, Eddie Drapkin wrote: > On Sat, May 23, 2009 at 2:58 AM, Ashley Sheridan > wrote: > > > > > If it's a CSV, I'd recommend using phpMyAdmin directly to import it into > > the database, assuming you are using a MySQL database that is. It's > > using tried and tested

Re: [PHP] fgets function for very large files

2009-05-23 Thread Michael A. Peters
shahrzad khorrami wrote: one thing! I need four fields of 7 fields in each line, in my code from original csv file first four of fields choose(mappping these fields with columns of table in db) for example: a line in csv file: "a","b","c","d","e","f","g" in table of database 4 column : name,ex

Re: [PHP] fgets function for very large files

2009-05-23 Thread shahrzad khorrami
one thing! I need four fields of 7 fields in each line, in my code from original csv file first four of fields choose(mappping these fields with columns of table in db) for example: a line in csv file: "a","b","c","d","e","f","g" in table of database 4 column : name,ext,tel,date that 4 field of

Re: [PHP] fgets function for very large files

2009-05-23 Thread shahrzad khorrami
Thanks for repply :) It must be automatically, it means that there is a form that an operator browse a csv with large size(more than 2-3 GB) and in next step(page) first 1000 line insert into db then by clicking on next button, next 1000 line operator don't know any thing about phpmyadmin and

Re: [PHP] fgets function for very large files

2009-05-23 Thread Eddie Drapkin
On Sat, May 23, 2009 at 2:58 AM, Ashley Sheridan wrote: > > If it's a CSV, I'd recommend using phpMyAdmin directly to import it into > the database, assuming you are using a MySQL database that is. It's > using tried and tested code for large files like that. > > Tried and true to be what, exactly

Re: [PHP] fgets function for very large files

2009-05-22 Thread Ashley Sheridan
On Sat, 2009-05-23 at 10:41 +0430, shahrzad khorrami wrote: > hi all, > > I have a csv file with more than 100,000 lines. I want to insert each line > as a record in a > database. but for the reason of very number of lines, > I put a button with caption Next, when we click on it, 1000 line will >

[PHP] fgets function for very large files

2009-05-22 Thread shahrzad khorrami
hi all, I have a csv file with more than 100,000 lines. I want to insert each line as a record in a database. but for the reason of very number of lines, I put a button with caption Next, when we click on it, 1000 line will insert into db and then again click next button and insert next 1000 line

Re: [PHP] fgets???

2008-02-14 Thread Richard Lynch
On Fri, February 8, 2008 11:54 am, Zoltán Németh wrote: > 2008. 02. 8, péntek keltezéssel 12.46-kor Daniel Brown ezt írta: >> On Feb 8, 2008 12:35 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: >> >> I knew it. After silence, Lynch comes back with a vengeance >> three hours before the week's

Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 12.46-kor Daniel Brown ezt írta: > On Feb 8, 2008 12:35 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: > > I knew it. After silence, Lynch comes back with a vengeance > three hours before the week's stats come out. > > And not only that he top-posts. ;

Re: [PHP] fgets???

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 12:35 PM, Richard Lynch <[EMAIL PROTECTED]> wrote: I knew it. After silence, Lynch comes back with a vengeance three hours before the week's stats come out. And not only that he top-posts. ;-P -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (ht

Re: [PHP] fgets???

2008-02-08 Thread Richard Lynch
The first possible issue is that the "newline" character[s] is different for Mac, Windows, and Linux... So if your file is one format, and fgets is expecting the other, it won't do what you want. The next is that if your code is wrong, and is showing it all as one line, it PROBABLY means you are

Re: [PHP] fgets???

2008-02-08 Thread Nirmalya Lahiri
--- Daniel Brown <[EMAIL PROTECTED]> wrote: > On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> > wrote: > > I think I may have written the question wrong. I only want to > display the > > first line. It is a news story with a headline. I only want to > display the > > headline in the lin

Re: [PHP] fgets???

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 12:19 PM, Zoltán Németh <[EMAIL PROTECTED]> wrote: > 2008. 02. 8, péntek keltezéssel 12.17-kor Daniel Brown ezt írta: > > On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> wrote: > > > I think I may have written the question wrong. I only want to display the > > > first line.

Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 12.17-kor Daniel Brown ezt írta: > On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> wrote: > > I think I may have written the question wrong. I only want to display the > > first line. It is a news story with a headline. I only want to display the > > headli

Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 11.11-kor Pastor Steve ezt írta: > I think I may have written the question wrong. I only want to display > the first line. It is a news story with a headline. I only want to > display the headline in the link. > > The output I want is: > > The > > But I am getting

Re: [PHP] fgets???

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> wrote: > I think I may have written the question wrong. I only want to display the > first line. It is a news story with a headline. I only want to display the > headline in the link. > > The output I want is: > > The > > But I am getting: >

Re: [PHP] fgets???

2008-02-08 Thread Pastor Steve
I think I may have written the question wrong. I only want to display the first line. It is a news story with a headline. I only want to display the headline in the link. The output I want is: The But I am getting: The file looks like this. Does that make more sense? Thanks, -- Steve M. on

Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta: > Is it possible to read each line of data from a file? > > I have a text file that has several lines on it. I only want to display the > first line only. > > The > file I have > looks like this. > > But outputs: > > "The file I

[PHP] fgets???

2008-02-08 Thread Pastor Steve
Is it possible to read each line of data from a file? I have a text file that has several lines on it. I only want to display the first line only. The file I have looks like this. But outputs: "The file I have looks like this." Here is my code: Breaking News Please che

[PHP] fgets fails after fopen succeeds -- cleaned up for better digestion.

2005-05-12 Thread Thomas Powell
I removed the "r+", since that not my intended mode. File Handle is 1 after the fopen call. fgets, feof, and fclose fail on $fh. (So does fread, FWIW). The file exists. fopen fails if it is moved. *Code:* 0) { print '' . $line ."\n"; } } ?> *Output:* ./outside/index.txt File Handle:1

Re: [PHP] fgets fails after fopen succeeds

2005-05-10 Thread Richard Lynch
On Tue, May 10, 2005 7:42 pm, Thomas Powell said: > Printing $fh printed a 1. > > My original file mode was just "r", I changed to "r+" to see if I'd get > permissions problems. The file handle seems to be fine. fgets just doesn't > like it. > > This is an adaptation of the following code, which wo

Re: [PHP] fgets fails after fopen succeeds

2005-05-10 Thread Richard Lynch
On Tue, May 10, 2005 1:34 pm, Thomas Powell said: > Summary: > fopen returns a file handle, yet fgets doesn't want to read it. I've > scoured > google, php.net , phpfreaks, usenet, etc. It seems to work > elsewhere. > > My setup: > Apache 2.0.47 > PHP/5.0.4 > Windows 2000 > > The ca

Re: [PHP] fgets fails after fopen succeeds

2005-05-10 Thread Thomas Powell
Printing $fh printed a 1. My original file mode was just "r", I changed to "r+" to see if I'd get permissions problems. The file handle seems to be fine. fgets just doesn't like it. The 0 && !feof() was a "commenting out" of the for loop to prevent the fgets from running so that I so print the

[PHP] fgets fails after fopen succeeds

2005-05-10 Thread Thomas Powell
Summary: fopen returns a file handle, yet fgets doesn't want to read it. I've scoured google, php.net , phpfreaks, usenet, etc. It seems to work elsewhere. My setup: Apache 2.0.47 PHP/5.0.4 Windows 2000 The call: make_link_list("index"); (the file exists for fopen(), and actual

Re: [PHP] fgets prob... !?

2003-09-29 Thread Marek Kilimajer
I don't think php just comes and changes your output. Check the source html output if it is realy only one #. mArK wrote: H! I have this segment of script... ... $resp = fgets( $sock, 512 ); echo $resp; ... the output must be: [EMAIL PROTECTED] but here came php and take the 3 "#" and convert

[PHP] fgets prob... !?

2003-09-28 Thread mArK
H! I have this segment of script... ... $resp = fgets( $sock, 512 ); echo $resp; ... the output must be: [EMAIL PROTECTED] but here came php and take the 3 "#" and convert they in only one "#", and the output currently is: [EMAIL PROTECTED] How I say to php: "STOP", leave my "#" in peace? --

Re: [PHP] fgets() problem

2003-06-13 Thread Marek Kilimajer
From the manual: Note: The length parameter became optional in PHP 4.2.0, if omitted, it would assume 1024 as the line length. As of PHP 4.3, omitting length will keep reading from the stream until it reaches the end of the line. If the majority of the lines in the file are all larger than 8KB,

[PHP] fgets() problem

2003-06-13 Thread Armand Turpel
It seems that some php versions have difficulties with the fgets() function. On php 4.3.2 it works fine, but other versions report warnings. fgets($f); Warning: Wrong parameter count for fgets() in /var/www/Xprotector/include/base.inc.php on line 70 If I change fgets to fgets($f, 4096); it w

Re: [PHP] fgets and Macs

2003-01-15 Thread Chris Shiflett
--- Jason Jacobs <[EMAIL PROTECTED]> wrote: > It would be wonderful if my php.ini file actually > contained the variable "auto_detect_line_endings." > How can I solve this problem? Try adding it yourself. Don't let its absence dissuade you from giving it a shot. :-) Chris -- PHP General Mailin

[PHP] fgets and Macs

2003-01-15 Thread Jason Jacobs
Hello all. I was doing some reading and found that fgets() doesn't work so well with a text file created on a mac, and php.net has a fix. It would be wonderful if my php.ini file actually contained the variable "auto_detect_line_endings." How can I solve this problem? Is my only solution (wi

Re: [PHP] fgets() question?

2002-12-22 Thread Jason Wong
On Sunday 22 December 2002 14:18, Noel Wade wrote: > Okay, attacking my flat-file issues from the other end: > > When you use $foo = fgets($fp_file); it appears that a blank line ends up > looking exactly like a FALSE ("failed to read") return value... Is there > any way to differentiate between

[PHP] fgets() question?

2002-12-21 Thread Noel Wade
Okay, attacking my flat-file issues from the other end: When you use $foo = fgets($fp_file); it appears that a blank line ends up looking exactly like a FALSE ("failed to read") return value... Is there any way to differentiate between an empty-string read (a blank line in a flat-file) and a FAL

[PHP] fgets()

2002-11-03 Thread Khalid El-Kary
hi, i want to open a remote file using fopen() i tried both of these ways $filename="http://www.domain.com/filename.txt";; $file=fopen($filename,"r"); $filecontents=fread($file,filesize($filename)); this one didn't work because it's apparent that the file isn't in the local file system so filesi

Re: [PHP] fgets question

2002-08-14 Thread Monte Ohrt
I don't have the option of editing the text files to work right. I want to be able to read an arbitrary text file line by line and process each one. So I suppose I could do this (?) DL Neil wrote: > Hi Monte, > > >>Hi, I have a question about fgets(), it seems to pick up an extra line >>at

Re: [PHP] fgets question

2002-08-14 Thread DL Neil
Hi Monte, > Hi, I have a question about fgets(), it seems to pick up an extra line > at the end of a text file. ... > 8\n ... > Here is the output (showing newlines as \n): > buffer is 1\n > buffer is 2\n > buffer is 3\n > buffer is 4\n > buffer is 5\n > buffer is 6\n > buffer is 7\n > buffer is

RE: [PHP] fgets question

2002-08-14 Thread Jay Blanchard
[snip] 1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A No extra newlines that I could see. >> >>1\n >>2\n >>3\n >>4\n >>5\n >>6\n >>7\n >>8\n >> >>I create this PHP program and run it: >> >>>$fd = fopen ("test","r"); >>while (!feof ($fd)) { >> $buffer = fgets($fd, 4096); >> echo "buffer is $buffer"; >>}

Re: [PHP] fgets question

2002-08-14 Thread Monte Ohrt
From: "Monte Ohrt" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, August 14, 2002 11:05 AM > Subject: [PHP] fgets question > > > >>Hi, I have a question about fgets(), it seems to pick up an extra line >>at the end of a text file.

Re: [PHP] fgets question

2002-08-14 Thread Kevin Stone
The only explaination is that 'vi' is putting an extra line in there that you're not seeing. -Kevin - Original Message - From: "Monte Ohrt" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 14, 2002 11:05 AM Subject: [PHP] fgets que

[PHP] fgets question

2002-08-14 Thread Monte Ohrt
Hi, I have a question about fgets(), it seems to pick up an extra line at the end of a text file. example, I open a new file named "test" with the vi editor and make it 8 lines long like so (showing newlines as \n): 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n I create this PHP program and run it: Here

Re: [PHP] php fgets()

2002-05-15 Thread Miguel Cruz
On Wed, 15 May 2002, arnaud gonzales wrote: > I'm newbie in php and i would like to clearly understand how can i use: > LENGTH in string fgets ( int fp [, int length]) > > "Returns a string of up to length - 1 bytes read from the file pointed to by > fp. Reading ends when length - 1 bytes ha

[PHP] php fgets()

2002-05-14 Thread arnaud gonzales
Hi, I'm newbie in php and i would like to clearly understand how can i use: LENGTH in string fgets ( int fp [, int length]) "Returns a string of up to length - 1 bytes read from the file pointed to by fp. Reading ends when length - 1 bytes have been read, on a newline (which is included in t

Re: [PHP] fgets and eval

2001-12-18 Thread Greg Donald
> Okay here is the situation. I am reading a file using fgets up until I hit a certain delimiter within the text. No problem there. This text file may or may not > contain php in the format . So I now have two variables $header and $footer which may or may not contain some php within them. I need

[PHP] fgets and eval

2001-12-18 Thread Gerard Onorato
Hello all, Okay here is the situation. I am reading a file using fgets up until I hit a certain delimiter within the text. No problem there. This text file may or may not contain php in the format . So I now have two variables $header and $footer which may or may not contain some php within th

Re: [PHP] fgets

2001-08-30 Thread Christian Reiniger
On Wednesday 29 August 2001 23:45, Christopher William Wesley wrote: > On Wed, 29 Aug 2001, Joseph Bannon wrote: > > I want to use fgets to get an image off the server and then print it. > > Kinda like if you call the script picture.php, an image will appear. > > How do I do > > I do this, with fo

Re: [PHP] fgets

2001-08-29 Thread Christopher William Wesley
On Wed, 29 Aug 2001, Joseph Bannon wrote: > I want to use fgets to get an image off the server and then print it. Kinda > like if you call the script picture.php, an image will appear. How do I do I do this, with fopen() and fpassthru() ... $im = fopen( "myImage.jpg", "r" ); if(

[PHP] fgets

2001-08-29 Thread Joseph Bannon
I want to use fgets to get an image off the server and then print it. Kinda like if you call the script picture.php, an image will appear. How do I do this? I'm trying to create a graphical counter with php. Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAI