Re: [PHP] fgetcsv doesn't return an array?

2012-03-18 Thread Tamara Temple
On Thu, 15 Mar 2012 12:09:53 -0500, Jay Blanchard  
jay.blanch...@sigmaphinothing.org sent:



I thought that fgetcsv returned an array. I can work with it like an
array but I get the following warning when using it

|Warning:  implode(): Invalid arguments passed on line 155

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because
$csvCurrentLine is not declared as an array. Adding a line to the code

153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the
script working, but it us annoying. Does anyone know the solution?

Thanks!

Jay
|


Just want to clarify something not directly related to the OP's question:

This:


153 |$csvCurrentLine = array();


Does not set a *type* for $csvCurrentLine, so if you're next line is this:


154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');


Any previous assignments are lost; the notion that presetting  
$csvCurrentLine to an array has no bearing when you then immediately  
set the same variable to something else.


The type $csvCurrentLine has after line 154 is entirely dependent on  
what fgetcsv() is returning, and nothing that happened prior to line  
154.



--
Tamara Temple
   aka tamouse__

May you never see a stranger's face in the mirror

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-18 Thread Lester Caine

Tamara Temple wrote:

On Thu, 15 Mar 2012 12:09:53 -0500, Jay Blanchard
jay.blanch...@sigmaphinothing.org sent:


I thought that fgetcsv returned an array. I can work with it like an
array but I get the following warning when using it

|Warning:  implode(): Invalid arguments passed on line 155

154$csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155$currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because
$csvCurrentLine is not declared as an array. Adding a line to the code

153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the
script working, but it us annoying. Does anyone know the solution?



Just want to clarify something not directly related to the OP's question:

This:


153 |$csvCurrentLine = array();


Does not set a *type* for $csvCurrentLine, so if you're next line is this:


154$csvCurrentLine = fgetcsv($csvFile, 4096, ',');


Any previous assignments are lost; the notion that presetting $csvCurrentLine to
an array has no bearing when you then immediately set the same variable to
something else.

The type $csvCurrentLine has after line 154 is entirely dependent on what
fgetcsv() is returning, and nothing that happened prior to line 154.


In this case, Jay's attempt to fix the problem was simply wrong. fgetcsv may 
well not return an array, and the error in this code was simply that situation. 
If an array is not returned by fgetcsv then there was an error, hence line 155 
fails every time you hit the 'EOF' condition.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-16 Thread Jay Blanchard

[snip]
 Not sure why, but ok. Thanks everyone!

An empty line would lead to $csvCurrentLine == array() which as a boolean would 
be false but would not necessarily mean EOF. By using === to check the value 
the expression will only evaluate to false at EOF or an error.

-Stuart

[/snip]

Makes perfect sense! I just wasn't reading it right.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jay Blanchard
I thought that fgetcsv returned an array. I can work with it like an 
array but I get the following warning when using it


|Warning:  implode(): Invalid arguments passed on line 155

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because 
$csvCurrentLine is not declared as an array. Adding a line to the code


153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the 
script working, but it us annoying. Does anyone know the solution?


Thanks!

Jay
|


Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Matijn Woudt
On Thu, Mar 15, 2012 at 6:09 PM, Jay Blanchard
jay.blanch...@sigmaphinothing.org wrote:
 I thought that fgetcsv returned an array. I can work with it like an array
 but I get the following warning when using it

 |Warning:  implode(): Invalid arguments passed on line 155

 154     $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
 155     $currentLine = implode(,, $csvCurrentLine);
 |

 Everything that I have read online indicates that it is because
 $csvCurrentLine is not declared as an array. Adding a line to the code

 153 |$csvCurrentLine = array();

 Does not get rid of the warning. The warning isn't interfering with the
 script working, but it us annoying. Does anyone know the solution?

 Thanks!

 Jay
 |

Are you using this in a loop or something? fgetcsv returns FALSE on
errors, including End Of File.

- Matijn

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jay Blanchard

On 3/15/2012 12:23 PM, Matijn Woudt wrote:

On Thu, Mar 15, 2012 at 6:09 PM, Jay Blanchard
jay.blanch...@sigmaphinothing.org  wrote:

I thought that fgetcsv returned an array. I can work with it like an array
but I get the following warning when using it

|Warning:  implode(): Invalid arguments passed on line 155

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because
$csvCurrentLine is not declared as an array. Adding a line to the code

153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the
script working, but it us annoying. Does anyone know the solution?

Thanks!

Jay
|

Are you using this in a loop or something? fgetcsv returns FALSE on
errors, including End Of File.

[/snip]

I am using it in a loop. End Of File is an error?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jim Lucas

On 03/15/2012 10:09 AM, Jay Blanchard wrote:

I thought that fgetcsv returned an array. I can work with it like an
array but I get the following warning when using it

|Warning: implode(): Invalid arguments passed on line 155

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);
|

Everything that I have read online indicates that it is because
$csvCurrentLine is not declared as an array. Adding a line to the code

153 |$csvCurrentLine = array();

Does not get rid of the warning. The warning isn't interfering with the
script working, but it us annoying. Does anyone know the solution?

Thanks!

Jay
|



From the manual

fgetcsv() returns NULL if an invalid handle is supplied or FALSE on 
other errors, including end of file.


do this

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
var_dump($csvCurrentLine);
155 $currentLine = implode(,, $csvCurrentLine);

What does it say about the variable from the failing line?

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Andrew Ballard
On Thu, Mar 15, 2012 at 1:29 PM, Jay Blanchard
jay.blanch...@sigmaphinothing.org wrote:
 On 3/15/2012 12:23 PM, Matijn Woudt wrote:

 On Thu, Mar 15, 2012 at 6:09 PM, Jay Blanchard
 jay.blanch...@sigmaphinothing.org  wrote:

 I thought that fgetcsv returned an array. I can work with it like an
 array
 but I get the following warning when using it

 |Warning:  implode(): Invalid arguments passed on line 155

 154     $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
 155     $currentLine = implode(,, $csvCurrentLine);
 |

 Everything that I have read online indicates that it is because
 $csvCurrentLine is not declared as an array. Adding a line to the code

 153 |$csvCurrentLine = array();

 Does not get rid of the warning. The warning isn't interfering with the
 script working, but it us annoying. Does anyone know the solution?

 Thanks!

 Jay
 |

 Are you using this in a loop or something? fgetcsv returns FALSE on
 errors, including End Of File.

 [/snip]

 I am using it in a loop. End Of File is an error?

Yes.  fgetcsv() returns NULL if an invalid handle is supplied or
FALSE on other errors, including end of file.

I usually use it in a while loop like this:

?php

while ($row = fgetcsv($csvFilePointer)) {
// ... process the row
}

?

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Lester Caine

Jay Blanchard wrote:

154 $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155 $currentLine = implode(,, $csvCurrentLine);



I am using it in a loop. End Of File is an error?


You certainly need to break out on $csvCurrentLine = false which indicates end 
of file at least.


My own 'loop' is
$row=0;
while (($data = fgetcsv($handle, 800, ,)) !== FALSE) {
  if ( $row ) $contact-RecordLoad( $data, $row );
$row++;
}
The row bit strips the header line from the csv file ...

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Matijn Woudt
On Thu, Mar 15, 2012 at 6:40 PM, Andrew Ballard aball...@gmail.com wrote:
 On Thu, Mar 15, 2012 at 1:29 PM, Jay Blanchard
 jay.blanch...@sigmaphinothing.org wrote:
 On 3/15/2012 12:23 PM, Matijn Woudt wrote:

 On Thu, Mar 15, 2012 at 6:09 PM, Jay Blanchard
 jay.blanch...@sigmaphinothing.org  wrote:

 I thought that fgetcsv returned an array. I can work with it like an
 array
 but I get the following warning when using it

 |Warning:  implode(): Invalid arguments passed on line 155

 154     $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
 155     $currentLine = implode(,, $csvCurrentLine);
 |

 Everything that I have read online indicates that it is because
 $csvCurrentLine is not declared as an array. Adding a line to the code

 153 |$csvCurrentLine = array();

 Does not get rid of the warning. The warning isn't interfering with the
 script working, but it us annoying. Does anyone know the solution?

 Thanks!

 Jay
 |

 Are you using this in a loop or something? fgetcsv returns FALSE on
 errors, including End Of File.

 [/snip]

 I am using it in a loop. End Of File is an error?

 Yes.  fgetcsv() returns NULL if an invalid handle is supplied or
 FALSE on other errors, including end of file.

 I usually use it in a while loop like this:

 ?php

 while ($row = fgetcsv($csvFilePointer)) {
    // ... process the row
 }

 ?

Please, don't do that. Use this instead:
while (($csvCurrentLine = fgetcsv($csvFile, 4096, ',')) !== FALSE) {
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Jay Blanchard
[snip]
 Please, don't do that. Use this instead:
 while (($csvCurrentLine = fgetcsv($csvFile, 4096, ',')) !== FALSE) {
 }
 [/snip]

Not sure why, but ok. Thanks everyone!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv doesn't return an array?

2012-03-15 Thread Stuart Dallas
On 15 Mar 2012, at 20:26, Jay Blanchard wrote:

 [snip]
 Please, don't do that. Use this instead:
 while (($csvCurrentLine = fgetcsv($csvFile, 4096, ',')) !== FALSE) {
 }
 [/snip]
 
 Not sure why, but ok. Thanks everyone!

An empty line would lead to $csvCurrentLine == array() which as a boolean would 
be false but would not necessarily mean EOF. By using === to check the value 
the expression will only evaluate to false at EOF or an error.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] fgetcsv

2008-01-09 Thread Danny Brow
Hi Everyone,

I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.


//Common for all trials
$demoID = fopen(newDemoID.csv, r);;
$ID = 43;

$data = fgetcsv($demoID);



First try with while:

/*
while ($data) {
if ($data[0] == $wolfID) {
print $data[1] . , . $data[2] . , . $data[3] .
.\n;
}
}
*/


Takes for every.

I can't use just the below because it only compares the first row.

/*
if ($data[0] == $wolfID) {
   print $data[1] . , . $data[2] . , . $data[3] . .\n;
}

*/


I know this is simple, but I've hit codes block due to lack of sleep. 

Thanks,
Dan



Sample Data:

 5,1,Smith,Myrtle
 6,2,Smith,Carita
 7,3,Smith,Paul
 8,4,Smith,Donald





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Jim Lucas

Danny Brow wrote:

Hi Everyone,

I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.


//Common for all trials
$demoID = fopen(newDemoID.csv, r);;
$ID = 43;

$data = fgetcsv($demoID);



First try with while:

/*
while ($data) {
if ($data[0] == $wolfID) {
print $data[1] . , . $data[2] . , . $data[3] .
.\n;
}
}
*/


Takes for every.

I can't use just the below because it only compares the first row.

/*
if ($data[0] == $wolfID) {
   print $data[1] . , . $data[2] . , . $data[3] . .\n;
}

*/


I know this is simple, but I've hit codes block due to lack of sleep. 


Thanks,
Dan



Sample Data:


5,1,Smith,Myrtle
6,2,Smith,Carita
7,3,Smith,Paul
8,4,Smith,Donald








Maybe try something like this.

?php

//Common for all trials
$fh = fopen(newDemoID.csv, r);;

# What we are looking for
$ID = 43;

# check for valid handle
if ( is_resource($fh) ) {

# Loop through file handler
# if we get data, we check it
# if/when we get false, we break out of the while loop
while ( ($data = fgetcsv($fh) ) !== false ) {

# Check for the value you are looking for.
if ( $data[0] == $ID ) {

# Obvious...
echo {$data[1]},{$data[2]},{$data[3]}\n;

}

}

fclose($fh);

}

?

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Daniel Brown
On Jan 9, 2008 5:35 PM, Danny Brow [EMAIL PROTECTED] wrote:
 Hi Everyone,

 I'm trying to compare a value to the first field in a csv fILE (example
 of the data below). Using while takes too long and I can't figure out
 how to compare just one row at a time. I've tried some variations of the
 following.


 //Common for all trials
 $demoID = fopen(newDemoID.csv, r);;
 $ID = 43;

 $data = fgetcsv($demoID);



 First try with while:

 /*
 while ($data) {
 if ($data[0] == $wolfID) {
 print $data[1] . , . $data[2] . , . $data[3] .
 .\n;
 }
 }
 */

As an alternative, you could try this:
?
$wolfID = 43;

$data = file_get_contents($filename);
$line = explode(\n,$data);

for($i=0;$icount($line);$i++) {
$field = explode(,,$line[$i]); // Replace the comma with your separator.
$match = str_replace(','',str_replace('','',$field[0])); //
Strip quotes, if they exist.
if($match == $wolfID) {
echo $line[$i].\n;
}
}
?


-- 
/Dan

Daniel P. Brown
Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since 1979.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Chris

Danny Brow wrote:

Hi Everyone,

I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.


So are you trying to compare the first column or the first row? You've 
said you want to compare both.


To compare the first row:

?php

$handle = fopen('file.csv', 'r') or die(unable to open file);

$my_row = array('1','2','John Smith');

$data = fgetcsv($handle, 1000, ,);

if ($data === false) {
echo Unable to get anything from the file.;
}

if (is_array($data)) {
if ($data == $my_row) {
echo The first row matched\n;
} else {
echo The first row didnt match\n;
}
}

fclose($handle);


If you really do want to compare the first column, then the time to do 
it will be based on how big the csv file is. If you have a big file, 
it's going to take a long time to go through each row and then look at 
the first field.


?php

$handle = fopen('file.csv', 'r') or die(unable to open file);

$my_value = '1';

$row_count = 0;
while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) {
$row_count++;
if ($data[0] == $my_value) {
echo Found my_value on row , $row_count, \n;
} else {
echo Did not find my_value on row , $row_count, \n;
}
}

fclose($handle);

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Danny Brow
I need to compare the first field of each row. But this idea is shot to
hell, i've been running one of the examples on the file and it's been
about an hour+ already... 6500 records have to be checked... I think
MySQL is calling my name right now.

Thanks,
Dan


On Thu, 2008-01-10 at 09:59 +1100, Chris wrote:
 Danny Brow wrote:
  Hi Everyone,
  
  I'm trying to compare a value to the first field in a csv fILE (example
  of the data below). Using while takes too long and I can't figure out
  how to compare just one row at a time. I've tried some variations of the
  following.
 
 So are you trying to compare the first column or the first row? You've 
 said you want to compare both.
 
 To compare the first row:
 
 ?php
 
 $handle = fopen('file.csv', 'r') or die(unable to open file);
 
 $my_row = array('1','2','John Smith');
 
 $data = fgetcsv($handle, 1000, ,);
 
 if ($data === false) {
   echo Unable to get anything from the file.;
 }
 
 if (is_array($data)) {
   if ($data == $my_row) {
   echo The first row matched\n;
   } else {
   echo The first row didnt match\n;
   }
 }
 
 fclose($handle);
 
 
 If you really do want to compare the first column, then the time to do 
 it will be based on how big the csv file is. If you have a big file, 
 it's going to take a long time to go through each row and then look at 
 the first field.
 
 ?php
 
 $handle = fopen('file.csv', 'r') or die(unable to open file);
 
 $my_value = '1';
 
 $row_count = 0;
 while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) {
   $row_count++;
   if ($data[0] == $my_value) {
   echo Found my_value on row , $row_count, \n;
   } else {
   echo Did not find my_value on row , $row_count, \n;
   }
 }
 
 fclose($handle);
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Jim Lucas

Danny Brow wrote:

I need to compare the first field of each row. But this idea is shot to
hell, i've been running one of the examples on the file and it's been
about an hour+ already... 6500 records have to be checked... I think
MySQL is calling my name right now.

Thanks,
Dan


On Thu, 2008-01-10 at 09:59 +1100, Chris wrote:

Danny Brow wrote:

Hi Everyone,

I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.
So are you trying to compare the first column or the first row? You've 
said you want to compare both.


To compare the first row:

?php

$handle = fopen('file.csv', 'r') or die(unable to open file);

$my_row = array('1','2','John Smith');

$data = fgetcsv($handle, 1000, ,);

if ($data === false) {
echo Unable to get anything from the file.;
}

if (is_array($data)) {
if ($data == $my_row) {
echo The first row matched\n;
} else {
echo The first row didnt match\n;
}
}

fclose($handle);


If you really do want to compare the first column, then the time to do 
it will be based on how big the csv file is. If you have a big file, 
it's going to take a long time to go through each row and then look at 
the first field.


?php

$handle = fopen('file.csv', 'r') or die(unable to open file);

$my_value = '1';

$row_count = 0;
while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) {
$row_count++;
if ($data[0] == $my_value) {
echo Found my_value on row , $row_count, \n;
} else {
echo Did not find my_value on row , $row_count, \n;
}
}

fclose($handle);

--
Postgresql  php tutorials
http://www.designmagick.com/






even on a slow machine 6500 records should be very fast.

Are you doing this through a web interface or command line?

If browser, are you sure that your script is still running?  Could the PHP 
timeout be exceeded?

Try the other example that I gave you.

pre?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

$st = microtime(true);

$file = '/tmp/testing.csv';

$fh = fopen($file, w+) or die('Could not open new file for writing');

for ( $i=0; $i1; $i++ ) {
fputcsv($fh, array($i,1,Smith{$i},Myrtle{$i}));
}

fclose($fh);

//Common for all trials
$fh = fopen($file, r) or die('Could not open file ({$file}) for reading');

# What we are looking for
$ID = ;

# Loop through file handler
# if we get data, we check it
# if/when we get false, we break out of the while loop
while ( ($data = fgetcsv($fh) ) !== false ) {

# Check for the value you are looking for.
if ( $data[0] == $ID ) {

# Obvious...
echo {$data[0]},{$data[1]},{$data[2]},{$data[3]}\n;

}

}

fclose($fh);

echo Run time was .round(microtime(true) - $st, 6). seconds.;

?

I looked for the last result, time for me was

,1,Smith,Myrtle
Run time was 0.04 seconds.



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv

2008-01-09 Thread Bastien Koert

http://ca.php.net/manual/en/function.fgetcsv.php
_
Discover new ways to stay in touch with Windows Live! Visit the City @ Live 
today!
http://getyourliveid.ca/?icid=LIVEIDENCA006
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Richard Lynch
On Wed, January 9, 2008 4:35 pm, Danny Brow wrote:
 I'm trying to compare a value to the first field in a csv fILE
 (example
 of the data below). Using while takes too long and I can't figure out
 how to compare just one row at a time. I've tried some variations of
 the
 following.


 //Common for all trials
 $demoID = fopen(newDemoID.csv, r);;
 $ID = 43;

 $data = fgetcsv($demoID);



 First try with while:

 /*
 while ($data) {
 if ($data[0] == $wolfID) {
 print $data[1] . , . $data[2] . , . $data[3] .
 .\n;
 }
 }
 */


 Takes for every.

*IF* the line you are looking for is almost always in the early rows,
and *IF* you only need the first match,
you can use the above and put a break; inside the if { }

This will let the script end as soon as it finds the answer.

You do have another $data = fgetcsv($demoID); inside the while loop,
right?

Otherwise you are looking at the same first line over and over and
over and over and over until PHP gives up on you.

 I can't use just the below because it only compares the first row.

 /*
 if ($data[0] == $wolfID) {
print $data[1] . , . $data[2] . , . $data[3] . .\n;
 }

 */


 I know this is simple, but I've hit codes block due to lack of sleep.

It's actually not simple at all, since you are trying to scan through
a large file (it must be large to take a long time) and find only one
chunk at the beginning of a row.

There are several other techniques to consider:
#1.
Put the data into an SQL database before you try to search for
specific field/value information.
SQL was designed to make this stuff fast.
CSV was designed to dump files out to pass between
spreadsheets/databases.

#2.
*IF* the file isn't TOO large compared to your available RAM, you
could load the whole thing with file_get_contents and then do some
preg magic to find the line you want:
$file = file_get_contents(/full/path/to/file);
preg_match(/^$wolfID,.*\$/ms, $file, $match);
var_dump($match);
//use preg_match_all to find ALL the lines that match

#3.
*IF* the file is too large, and *IF* the CSV parsing is the slow part
(which I doubt) it's possible that a simple fgets() and simple check
sch as:
if (substr($line, 0, strlen($wolfID)) == $wolfID)
would be faster...
Actually, pull the strlen($wolfID) out of the loop into a variable,
and maybe use strpos instead of substr instead and...
The biggest time sink is probably reading the file line by line,
though, not the actual processing which is pretty minimal... In which
case this solution will probably not significantly beat your current
time.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Richard Lynch
6500 rows is chump-change.

You probably don't have the fgetcsv inside the while loop to get past
the first row... :-)

On Wed, January 9, 2008 6:09 pm, Danny Brow wrote:
 I need to compare the first field of each row. But this idea is shot
 to
 hell, i've been running one of the examples on the file and it's been
 about an hour+ already... 6500 records have to be checked... I think
 MySQL is calling my name right now.

 Thanks,
 Dan


 On Thu, 2008-01-10 at 09:59 +1100, Chris wrote:
 Danny Brow wrote:
  Hi Everyone,
 
  I'm trying to compare a value to the first field in a csv fILE
 (example
  of the data below). Using while takes too long and I can't figure
 out
  how to compare just one row at a time. I've tried some variations
 of the
  following.

 So are you trying to compare the first column or the first row?
 You've
 said you want to compare both.

 To compare the first row:

 ?php

 $handle = fopen('file.csv', 'r') or die(unable to open file);

 $my_row = array('1','2','John Smith');

 $data = fgetcsv($handle, 1000, ,);

 if ($data === false) {
  echo Unable to get anything from the file.;
 }

 if (is_array($data)) {
  if ($data == $my_row) {
  echo The first row matched\n;
  } else {
  echo The first row didnt match\n;
  }
 }

 fclose($handle);


 If you really do want to compare the first column, then the time to
 do
 it will be based on how big the csv file is. If you have a big file,
 it's going to take a long time to go through each row and then look
 at
 the first field.

 ?php

 $handle = fopen('file.csv', 'r') or die(unable to open file);

 $my_value = '1';

 $row_count = 0;
 while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) {
  $row_count++;
  if ($data[0] == $my_value) {
  echo Found my_value on row , $row_count, \n;
  } else {
  echo Did not find my_value on row , $row_count, \n;
  }
 }

 fclose($handle);

 --
 Postgresql  php tutorials
 http://www.designmagick.com/



 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv

2008-01-09 Thread Danny Brow
Um, I've read the manual.


On Wed, 2008-01-09 at 20:11 -0500, Bastien Koert wrote:
 http://ca.php.net/manual/en/function.fgetcsv.php
 _
 Discover new ways to stay in touch with Windows Live! Visit the City @ Live 
 today!
 http://getyourliveid.ca/?icid=LIVEIDENCA006
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2008-01-09 Thread Danny Brow
You are so right, takes all of 0.122 s to process the whole file with
the fgetcsv inside the while loop Guess I need to look up why this
was the problem.

Thanks everyone!


On Wed, 2008-01-09 at 20:59 -0600, Richard Lynch wrote:
 6500 rows is chump-change.
 
 You probably don't have the fgetcsv inside the while loop to get past
 the first row... :-)
 
 On Wed, January 9, 2008 6:09 pm, Danny Brow wrote:
  I need to compare the first field of each row. But this idea is shot
  to
  hell, i've been running one of the examples on the file and it's been
  about an hour+ already... 6500 records have to be checked... I think
  MySQL is calling my name right now.
 
  Thanks,
  Dan
 
 
  On Thu, 2008-01-10 at 09:59 +1100, Chris wrote:
  Danny Brow wrote:
   Hi Everyone,
  
   I'm trying to compare a value to the first field in a csv fILE
  (example
   of the data below). Using while takes too long and I can't figure
  out
   how to compare just one row at a time. I've tried some variations
  of the
   following.
 
  So are you trying to compare the first column or the first row?
  You've
  said you want to compare both.
 
  To compare the first row:
 
  ?php
 
  $handle = fopen('file.csv', 'r') or die(unable to open file);
 
  $my_row = array('1','2','John Smith');
 
  $data = fgetcsv($handle, 1000, ,);
 
  if ($data === false) {
 echo Unable to get anything from the file.;
  }
 
  if (is_array($data)) {
 if ($data == $my_row) {
 echo The first row matched\n;
 } else {
 echo The first row didnt match\n;
 }
  }
 
  fclose($handle);
 
 
  If you really do want to compare the first column, then the time to
  do
  it will be based on how big the csv file is. If you have a big file,
  it's going to take a long time to go through each row and then look
  at
  the first field.
 
  ?php
 
  $handle = fopen('file.csv', 'r') or die(unable to open file);
 
  $my_value = '1';
 
  $row_count = 0;
  while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) {
 $row_count++;
 if ($data[0] == $my_value) {
 echo Found my_value on row , $row_count, \n;
 } else {
 echo Did not find my_value on row , $row_count, \n;
 }
  }
 
  fclose($handle);
 
  --
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 
 
  --
  This message has been scanned for viruses and
  dangerous content by MailScanner, and is
  believed to be clean.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 -- 
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some indie artist.
 http://cdbaby.com/from/lynch
 Yeah, I get a buck. So?
 
 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] fgetcsv() excel data missing

2005-02-18 Thread Binoy AV
Hi all,

   I used fgetcsv() function to get the data from a excel file.
 While reading the data it shows some special characters . 
 I found the same problems in 
  http://bugs.php.net/bug.php?id=12127edit=2 
  Is it a bug?

 Plz help me. 

Binoy 

 
__ __ __ __
Sent via the WebMail system at softwareassociates.co.uk


 
   
---
Scanned by MessageExchange.net (13:31:20 SPITFIRE)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Jay Blanchard
[snip]
   I used fgetcsv() function to get the data from a excel file.
 While reading the data it shows some special characters . 
 I found the same problems in 
  http://bugs.php.net/bug.php?id=12127edit=2 
  Is it a bug?
[/snip]

What special characters does it show?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Binoy AV

 Hi,

Thanks for the reply.

 It shows  ÐÏࡱá\\þÿ etc.

 source code I used is

  $handle = fopen (file.xls,r);
  while ($data = fgetcsv ($handle, 1000, ,))
  {
   $num = count($data);
   for ($c=0; $c  $num ; $c++)
   {
$str_email = $data[$c];
 echo $str_email;

   }
  }

 Binoy


__ __ __ __
Sent via the WebMail system at softwareassociates.co.uk





---
Scanned by MessageExchange.net (13:55:17 SPITFIRE)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Jay Blanchard
[snip]
Thanks for the reply.

 It shows  ÐÏࡱá\\þÿ etc.

 source code I used is

  $handle = fopen (file.xls,r); 
  while ($data = fgetcsv ($handle, 1000, ,)) 
  { 
   $num = count($data); 
   for ($c=0; $c  $num ; $c++) 
   { 
$str_email = $data[$c];
 echo $str_email;

   }
  }

[/snip]

You have to save the .xls file as a .csv file, then you can open and getcsv

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Binoy AV
 Thanks Jay.
  
  Could anybody please tell me how to read the data from an excel file ? It 
should work independent of the operating system. I don't want the csv format. 


Binoy
   

 
__ __ __ __
Sent via the WebMail system at softwareassociates.co.uk


 
   
---
Scanned by MessageExchange.net (14:20:44 SPITFIRE)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Jay Blanchard
[snip]
  Could anybody please tell me how to read the data from an excel file ?
It should work independent of the operating system. I don't want the csv
format. 
[/snip]

Start here http://us4.php.net/com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv() excel data missing

2005-02-18 Thread M. Sokolewicz
Binoy AV wrote:
 Thanks Jay.
  
  Could anybody please tell me how to read the data from an excel file ? It should work independent of the operating system. I don't want the csv format. 
excel files aren't independent of the OS, csv files are. Excel files 
need to be parsed, because they contain heaps of formatting data. If 
you're using php on a windows OS, then you can use COM or .NET to read 
it in. On other systems however, you'll likely run into problems pretty 
quickly, and will most probably need to write your own parser routine

Binoy
   

 
__ __ __ __
Sent via the WebMail system at softwareassociates.co.uk

 
   
---
Scanned by MessageExchange.net (14:20:44 SPITFIRE)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Bret Hughes
On Fri, 2005-02-18 at 09:12, M. Sokolewicz wrote:
 Binoy AV wrote:
 
   Thanks Jay.

Could anybody please tell me how to read the data from an excel
file ? It should work independent of the operating system. I don't want
the csv format. 


 excel files aren't independent of the OS, csv files are. Excel files 
 need to be parsed, because they contain heaps of formatting data. If 
 you're using php on a windows OS, then you can use COM or .NET to read 
 it in. On other systems however, you'll likely run into problems pretty 
 quickly, and will most probably need to write your own parser routine
  

Not to mention the different versions of excel that alter the format.

Bret

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Richard Lynch
Binoy AV wrote:
   Could anybody please tell me how to read the data from an excel file ?
 It should work independent of the operating system. I don't want the csv
 format.

For your first step, you'll have to convince Microsoft to OpenSource their
code...

Oh, yeah.

You can't do that.

:-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] fgetcsv

2003-11-16 Thread zhuravlev alexander
Hello.

I wonder if PHP has fgetcsv() function why doesn't
PHP has fputcsv ?

 -- zhuravlev alexander
   u l s t u  n o c
 ([EMAIL PROTECTED])

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv

2003-11-16 Thread Derek Ford
zhuravlev alexander wrote:

	Hello.

I wonder if PHP has fgetcsv() function why doesn't
PHP has fputcsv ?
-- zhuravlev alexander
  u l s t u  n o c
([EMAIL PROTECTED])
 

because it would be bloat, basically. We now have file_put_contents in 
php5, which I like...but still view as bloat. You can easily enough use 
fopen and fwrite to add content to the csv file.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] fgetcsv quit working......

2003-03-09 Thread CDitty
I have a customer who's webhost upgraded their server recently and a script 
that was working fine quit working.  The error they are getting is this 
fgetcsv(): supplied argument is not a valid stream resource.  I don't 
know what they did with Apache, but as far as I know, nothing else changed.

Can anyone offer any advice on troubleshooting this one?

Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fgetcsv quit working......

2003-03-09 Thread Jason Sheets
Check to make sure the file exists, you should probably through some
debug code around the area that is failing.

Jason
On Sun, 2003-03-09 at 18:50, CDitty wrote:
 I have a customer who's webhost upgraded their server recently and a script 
 that was working fine quit working.  The error they are getting is this 
 fgetcsv(): supplied argument is not a valid stream resource.  I don't 
 know what they did with Apache, but as far as I know, nothing else changed.
 
 Can anyone offer any advice on troubleshooting this one?
 
 Chris
-- 
Jason Sheets [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fgetcsv quit working......

2003-03-09 Thread CDitty
I thought about this possibility, but it turns out 4 different scripts on 
the same server accessing different files from different locations and 
using different methods are all failing.

Chris

At 07:53 PM 3/9/2003, Jason Sheets wrote:
Check to make sure the file exists, you should probably through some
debug code around the area that is failing.
Jason
On Sun, 2003-03-09 at 18:50, CDitty wrote:
 I have a customer who's webhost upgraded their server recently and a 
script
 that was working fine quit working.  The error they are getting is this
 fgetcsv(): supplied argument is not a valid stream resource.  I don't
 know what they did with Apache, but as far as I know, nothing else changed.

 Can anyone offer any advice on troubleshooting this one?

 Chris
--
Jason Sheets [EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fgetcsv Help

2002-12-12 Thread @ Edwin
Hello,

Justin French [EMAIL PROTECTED] wrote:

[snip]
 Sample line from your CSV should look like this:
 
 ---
 1,foo,harry said \what is it?\,foo
 1,bah,\don't know\ said sally,something
 ---
 
 When echoing these values to the browser, you would strip the slashes.
[/snip]

The double quotes aren't really necessary unless
1. You have a comma in the field
2. You have double quotes in the field

So,

  1,foo,Harry said what is it,foo

would have no problem with fgetcsv().

And, btw, the  are also escaped with another .

- E

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fgetcsv Help

2002-12-11 Thread Richard Baskett
I am parsing a csv file with fgetcsv and the fields are surrounding by
double quotes, now I am running into a problem periodically that when there
are quotes within the value it is treating it like another value instead of
the same value.

Any ideas on how to get around that?

I am thinking I might have to convert all quotes to quot; and then turn all
quot;,quot; back into quotes and then the first quot; in the file and
then last one since obviously they will not have a comma in between them.
This seems like a while lot of work..

Ideas?

Rick

A wise women once said:  No one can help everybody, but everybody can help
somebody. - Unknown 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] fgetcsv Help

2002-12-11 Thread DL Neil
Richard,

 I am parsing a csv file with fgetcsv and the fields are surrounding by
 double quotes, now I am running into a problem periodically that when
there
 are quotes within the value it is treating it like another value instead
of
 the same value.
 Any ideas on how to get around that?

 I am thinking I might have to convert all quotes to quot; and then turn
all
 quot;,quot; back into quotes and then the first quot; in the file and
 then last one since obviously they will not have a comma in between them.
 This seems like a while lot of work..
 Ideas?


The first idea is that the system that outputs a .CSV with quotes within a
quoted field is broken big-time and that's the part that needs fixing!

I'm on the same wavelength as you describe: you can't use any automated csv
function on such a file. Quotes should only appear in pairs. The closing
quote must therefore appear immediately prior to a field separator (eg
comma) - whitespace not withstanding, unless it is the last field on a line,
in which case it will appear immediately prior to a record separator.

One possibility is to write a 'filter' script to do this - and thus leave
your existing code intact. The filter could take in the file, explode on
quotes, and then cycle through the resultant array looking at the first
non-whitespace data in every second element, clean/recode where necessary,
and then implode and output.

Alternatively could join/unset consecutive array elements which have been
split inappropriately (by 'internal' quotes), and then implode using the
other style of quotes/another separator, if this can be made to work later
in the process...

What a palaver!
=dn


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] fgetcsv Help

2002-12-11 Thread Justin French
How is the CSV being generated?  Seems to me like your problem isn't
ggetcsv(), but rather the file itself.

Commonly, a CSV file is a series of values, separated by a comma (duh!!).

The separated values are generally enclosed in double quotes (), as it
would appear yours are.

Any double quotes within each value (eg: she said hello) are escaped with
a slash (eg: she said \hello\).

If you are generating the CSV, then you can addslashes() to each value to
escape the quotes, and then later on, stripslashes() to get rid of them.


Sample line from your CSV should look like this:

---
1,foo,harry said \what is it?\,foo
1,bah,\don't know\ said sally,something
---

When echoing these values to the browser, you would strip the slashes.


Cheers,

Justin


on 11/12/02 7:13 PM, Richard Baskett ([EMAIL PROTECTED]) wrote:

 I am parsing a csv file with fgetcsv and the fields are surrounding by
 double quotes, now I am running into a problem periodically that when there
 are quotes within the value it is treating it like another value instead of
 the same value.
 
 Any ideas on how to get around that?
 
 I am thinking I might have to convert all quotes to quot; and then turn all
 quot;,quot; back into quotes and then the first quot; in the file and
 then last one since obviously they will not have a comma in between them.
 This seems like a while lot of work..
 
 Ideas?
 
 Rick
 
 A wise women once said:  No one can help everybody, but everybody can help
 somebody. - Unknown
 

Justin French

http://Indent.com.au
Web Development  
Graphic Design



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] fgetcsv Help

2002-12-11 Thread Richard Baskett
I did email the company that the csv feed is coming from so we'll see what
comes of that.  I really hope they fix it.

Well here is what I did to solve the problem:

I pulled the csv file in using file(), then found the string length, used
substr() to get rid of the first double quote in the line and the newline
and double quote at the end of the line.  Then I replaced all double quotes
with it's html entity equivalent.  Then replaced quot;,quot; back into ,
since that means those quotes are supposed to be there.. hopefully :)

then I just stuck quotes on the beginning and end of the line.

Created a new file and flushed the data into a new file.

If anybody needs the code, I can send it to them.  Hopefully though the
company will get this fixed!  Cheers!

Rick

 I am parsing a csv file with fgetcsv and the fields are surrounding by
 double quotes, now I am running into a problem periodically that when there
 are quotes within the value it is treating it like another value instead of
 the same value.
 Any ideas on how to get around that?
 
 I am thinking I might have to convert all quotes to quot; and then turn all
 quot;,quot; back into quotes and then the first quot; in the file and
 then last one since obviously they will not have a comma in between them.
 This seems like a while lot of work..
 Ideas?

The happiest people are those who think the most interesting thoughts.
Those who decide to use leisure as a means of mental development, who love
good music, good books, good pictures, good company, good conversation, are
the happiest people in the world. And they are not only happy in themselves,
they are the cause of happiness in others. - Phelps


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fgetcsv and end of line in values

2002-11-07 Thread svenie
greetings,

i have problems using fgetcsv to explode a .csv file. some values consist 
of line-breaks. although these values are enclosed by quotes, php 
recognizes the line-break and starts a new dataset.

the script workes fine in my old environment (win2k, apache 1.3.23, php 
4.1.1), the problem occures in my new environment (win2k, apache 2.0.43, 
php 4.3.0). maybe config-params?

i mentioned a new enclusure-attribute in fgetcsv since php 4.3.0. but 
experimenting with this didn't succeed. i also tried some different 
syntaxes in the delimiter-attrib of fgetcsv, no success.

does anybody have any suggestion?

thx.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] fgetcsv or other

2002-10-12 Thread @ Edwin

Hello,

Just remember that fgetcsv() returns an array. So the first column is

  $thearray[0];

You can just pass it to the function that generates the image BEFORE you go
to the next line of your csv file.

Or, am I missing something?

- E

On Saturday, October 12, 2002 2:05 AM
Bryan Koschmann wrote:

 Hi,

 I need to read from a csv file (with quotes). I use the example from the
 manual, and it does spit it out how I want it, but I need to access one of
 the fields and pass that data to something else.

 So it's like this, I need my csv file to be displayed in a table, but the
 last column will contain an image generate using data from the first
 column.

 Does anyone have any examples? I've been searching the net, but haven't
 really found much.

 Thanks!

 Bryan


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fgetcsv or other

2002-10-11 Thread Bryan Koschmann - GKT

Hi,

I need to read from a csv file (with quotes). I use the example from the
manual, and it does spit it out how I want it, but I need to access one of
the fields and pass that data to something else.

So it's like this, I need my csv file to be displayed in a table, but the
last column will contain an image generate using data from the first
column.

Does anyone have any examples? I've been searching the net, but haven't
really found much.

Thanks!

Bryan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fgetcsv With a String?

2002-05-14 Thread Jonathan Rosenberg

Is there any way that I can use fgetcsv, but have it get its
input from a string, instead of using a file pointer?

From the online docs, there doesn't seem to be a way, but I
thought I'd check with the list.

--
JR


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fgetcsv

2001-05-13 Thread Steve Wade

Hi all - just wondering if anyone knows of a function like fputcsv - that
is, writes a line to a csv file - opposite of fgetcsv.

Any help would be appreciated :-)

swadie

~~~
Steve Wade
Youth Outreach Coordinator
Fusion Australia Ltd (Sydney North)
ABN 26 001 273 105
+61 2 9477 1110




RE: [PHP] fgetcsv

2001-05-13 Thread Jason Murray

 Hi all - just wondering if anyone knows of a function like 
 fputcsv - that is, writes a line to a csv file - opposite of fgetcsv.

A CSV file is just a text file with a different file extension,
so you can use fgets to write it out...

Jason

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]