Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14752 > unrolled thread

PHP CSV

Started byJoydeep Chakrabarty <chalao.adda@gmail.com>
First post2014-12-18 17:09 +0530
Last post2014-12-18 15:16 +0100
Articles 3 on this page of 63 — 13 participants

Back to article view | Back to comp.lang.php


Contents

  PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 17:09 +0530
    Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 13:11 +0100
      Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-18 13:27 +0100
        Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 18:26 +0530
          Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 14:43 +0100
            Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-18 09:24 -0500
            Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 20:56 +0530
              Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 16:57 +0100
                Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-18 17:04 +0100
                Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 21:52 +0530
                  Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 17:38 +0100
                    Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 16:49 +0000
                  Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-18 21:34 -0500
                    Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2014-12-19 09:43 +0000
                      Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-19 14:05 +0100
                        Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-19 10:59 -0500
                          Re: PHP CSV Matthew Carter <m@ahungry.com> - 2014-12-19 14:21 -0500
                            Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-19 18:17 -0500
                            Re: PHP CSV "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-12-20 00:35 +0100
                          Re: PHP CSV Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-04 13:19 +0100
                            Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 08:03 -0500
                              Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 13:29 +0000
                                Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 09:06 -0500
                                  Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 15:26 +0000
                                    Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 10:40 -0500
                                      Re: PHP CSV Paul Herber <paul@pherber.com> - 2015-02-04 16:11 +0000
                                        Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 11:23 -0500
                                          Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 17:08 +0000
                                            Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 12:48 -0500
                                      Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 17:05 +0000
                                        Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 12:49 -0500
                                          Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 18:14 +0000
                                            Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 13:37 -0500
                                              Re: PHP CSV Matthew Carter <m@ahungry.com> - 2015-02-04 15:23 -0500
                                                Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-04 21:54 +0100
                                                  Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 16:32 -0500
                                                Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 16:31 -0500
                                  Re: PHP CSV Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-04 16:39 +0100
                                    Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 10:57 -0500
                                      Re: PHP CSV Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-04 18:07 +0100
                                        Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 12:55 -0500
                                    Re: PHP CSV Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-06 23:26 +0100
                                      Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 01:38 +0100
                                        Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-06 19:44 -0500
                                          Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 14:49 +0100
                                        Re: PHP CSV Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-07 14:28 +0100
                                      Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-06 19:42 -0500
                                        Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 04:33 +0100
                                          Re: PHP CSV Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-07 14:26 +0100
                                            Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 14:45 +0100
                                              Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-07 08:54 -0500
                                                Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 16:54 +0100
                                                  Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-07 11:00 -0500
                                          Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-07 08:51 -0500
                                            Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 14:55 +0100
          Re: PHP CSV Olaf Schmitt <thesys@gmx.de> - 2014-12-19 01:16 +0100
          Re: PHP CSV Denis McMahon <denismfmcmahon@gmail.com> - 2014-12-19 02:14 +0000
      Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 18:13 +0530
        Re: PHP CSV Derek Turner <frderek@cesmail.net> - 2014-12-18 12:55 +0000
          Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 18:33 +0530
            Re: PHP CSV Derek Turner <frderek@cesmail.net> - 2014-12-18 13:10 +0000
        Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-18 08:17 -0500
        Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-18 15:16 +0100

Page 4 of 4 — ← Prev page 1 2 3 [4]


#14759

FromDerek Turner <frderek@cesmail.net>
Date2014-12-18 13:10 +0000
Message-ID<cfg220FniudU2@mid.individual.net>
In reply to#14758
On Thu, 18 Dec 2014 18:33:14 +0530, Joydeep Chakrabarty wrote:

> You might be talking about allow_url_fopen flag. I checked that. It is
> on.

I was, and I was wrong: the default is "on".

[toc] | [prev] | [next] | [standalone]


#14760

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-12-18 08:17 -0500
Message-ID<m6uk3u$3p8$1@dont-email.me>
In reply to#14755
On 12/18/2014 7:43 AM, Joydeep Chakrabarty wrote:
> Markus Heinz wrote:
> 
>> Hello.
>>
>> On 2014-12-18 at 12:39 Joydeep Chakrabarty wrote:
>>> Hello,
>>>
>>> I am trying to read a CSV file from my web server. Here is my code.
>>>
>>> <?php
>>>      $file = "http://localhost/x.csv";
>>>      $fp = fopen ($file, "r");
>>>      if (!$file) {
>>>          echo "<p>Unable to open remote file.\n";
>>>          exit;
>>>      }
>>>      while(!feof($fp)) {
>>>          $data = fgetcsv($file, 1024);
>>>          print "Data = " . $data[0] . "<BR>";
>>>      }
>>>      fclose($fp);
>>> ?>
>>>
>>> It can access my csv file in my document root folder. But it gets into
>>> infinite loop and does not display anything from $data array. Is there
>>> something I am missing?
>>> Please help.
>>
>> You do not check correctly if the file has been opened. It looks like
>> you have interchanged $file and $fp in the if statement. So my
>> assumption is the file is not opened at all and this causes the infinite
>> loop because feof will return false if the file pointer is not valid.
>>
>> Furthermore you should consider using a local path in the fopen call if
>> the CSV file is on the same server anyways.
>>
>> Regards
>>
>> Markus
> Hello,
> 
> Sorry, that's a mistake. I changed that to $fp, but, still having the same 
> problem. It's going into infinite loop and taking too much time to load. I 
> put echo statement at every line to see whether file exists or not, whether 
> file opens right or not, etc.
> 
> Thanks.
> 
> 
> For local path, it's working.
> 

What happens if you try to access http://localhost/x.csv from a browser?

Did you follow Christoph's suggestion to check the return value of
fgetcsv() instead of using feof()?


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14762

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2014-12-18 15:16 +0100
Message-ID<m6unjm$iao$1@solani.org>
In reply to#14755
Joydeep Chakrabarty wrote:

> Sorry, that's a mistake. I changed that to $fp, but, still having the same 
> problem. It's going into infinite loop and taking too much time to load. I 
> put echo statement at every line to see whether file exists or not, whether 
> file opens right or not, etc.
> 
> For local path, it's working.

Are you sure there is an infinite loop, or is it just that the script
hangs?  The former should cause respective CPU load; the latter not.

If you're using the built-in web server of PHP, the script will hang,
because this web server is not able to handle nested requests to itself.

-- 
Christoph M. Becker

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

Back to top | Article view | comp.lang.php


csiph-web