You can invert your {'fields': [{'field':'fname', 'col':2}, {'field':'ssn',
'col':5}]} to something like ['field0', 'field1', 'fname', 'field3',
'field4', 'ssn'] and then zip it (Enumerable#zip) with every CSV row.
--
You received this message because you are subscribed to the Google Groups
Jason,
Why do you copy the return array into an other one before using it?
(and why rewriting code already available as native PHP functions?)
This should do the same than your code:
$fh = fopen($filename);
$fields = fgetcsv($fh);
while($line = fgetcsv($fh) !== false)
{
print
Eric - that is smoother, I'll update my scripts to run it that way
thanks!
On Aug 22, 5:01 am, Eric lefauv...@gmail.com wrote:
Jason,
Why do you copy the return array into an other one before using it?
(and why rewriting code already available as native PHP functions?)
This should do
Client side only.. I have something written but not sure I'm taking
advantage of prototype added methods for arrays and enumerations.
Basically, I'm constructing a csv from json object iterating over it's data
array, and appending to CSV like:
csv+=data
csv+=','
csv+='\n'
The above is
I would use a small PHP script (assuming the first line is the field
names)
$fields = array();
$data = array();
$fh = fopen($filename);
$line = fgetcsv($fh);
foreach($line as $n)
{
$fields[] = $n;
}
while($line = fgetcsv($fh) !== false)
{
foreach($line as $key = $n)
{
$data[$fields[$key]][] =