Re: manipulating CSV files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sure, just use the code I/we provided as the basis for what you need.

When you get stuck, post your code and we'll be happy to look at it for you.

Wolf

---- pere roca <peroc79@xxxxxxxxx> wrote: 
> 
>   hi Wolf and Jim, thanks for the answer!  Very useful.
>   Now  It would be wondeful if I can pick up the values from a CSV file
> (coordinates) and apply a postGIS/postgreSQL function (Select ...) to this
> data and add the resulting values as a new filed in the CSV !
> 
>   Is that possible?
> 
>   Thanks,
>   Pere
> 
> Wolf-6 wrote:
> > 
> > /////////////////////////
> >  $filename=""; // Name of your CSV file
> >  $file_path = ""; // whatever your files are pathed
> >  $filename = $file_path.$filename;
> >  $handle = @fopen($filename, "r");
> >  $k=0;
> >  $entry = $file_path . "entry_file.txt"; // I use this to make a new entry
> > file
> >  $entry_file = fopen($entry, 'w');
> >  $file_data = "dummy";
> >  if (!$entry_file){die("Unable to open $entry_file");}
> >  if ($handle)
> >  {
> >   echo "$filename opened successfully!<BR>";
> >   flush();
> >   while (!feof($handle)) 
> >   {
> >    $file_date = $name;  // use this for adding the name for each one
> >    $file_data .= fgets($handle, 4096);
> >    fwrite($entry_file, $file_data);
> >    echo "$file_data written to $entry";
> >    flush();
> >   }
> >  }
> >  fclose($handle);
> >  fclose($entry_file);
> > }
> > else
> > { die("Error opening $filename"); }
> > 
> > /////////////////////////
> > 
> > 
> > ---- pere roca <peroc79@xxxxxxxxx> wrote: 
> >> 
> >>   hi folks,
> >>   
> >>   I have a CSV file. Data is separated by ','. For example:
> >>   -94.86524,42.059444,A,B,X
> >>   -96.86524,42.059444,A,B,Y1
> >>   -99.86524,42.059444,A,B,C1 
> >> 
> >>   I want to interactively insert the user_name (passed by a php variable)
> >> into the first "field" to insert then on my DataBase. 
> >> 
> >>   Peter,-94.86524,42.059444,A,B,X
> >>   Jan,-96.86524,42.059444,A,B,Y1
> >>   ...
> >>   I know there is a command (fwrite) to write, but I can't figure out how
> >> to
> >> start with it... 
> >>   Afet open csv, etc. I think I should first check when there is a
> >> "return"
> >> (we change of file), then I add the "user_name" parameter and repeat it
> >> as
> >> long as there is some record.  
> >>   
> >>   Any workaround or code doing something similar for a newbie in php,
> >> please?
> >>   Thanks,
> >> 
> >>    Pere
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/manipulating-CSV-files-tf4548721.html#a12980387
> >> Sent from the PHP - General mailing list archive at Nabble.com.
> >> 
> >> -- 
> >> 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
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/manipulating-CSV-files-tf4548721.html#a13016318
> Sent from the PHP - General mailing list archive at Nabble.com.
> 
> -- 
> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux