<?php
use Port\Csv\CsvWriter;
use Port\Reader\ArrayReader;
use Port\Steps\StepAggregator;
use Port\Steps\Step\ValueConverterStep;
// Your input data
$reader = new ArrayReader(array(
array(
'first', // This is for the CSV header
'last',
array(
'first' => 'james',
'last' => 'Bond'
),
array(
'first' => 'hugo',
'last' => 'Drax'
)
))
);
// Create the workflow from the reader
$workflow = new StepAggregator($reader);
// Add the writer to the workflow
$workflow->addWriter(new CsvWriter(STDOUT));
// As you can see in the input data, the first names are not capitalized
// correctly. Let's fix that with a value converter:
$valueConverterStep = new ValueConverterStep();
$valueConverterStep->add('first', function ($value) {
return ucfirst($value);
});
$workflow->addStep($valueConverterStep);
// Process the workflow
$workflow->process();
0.0182 571640 2. Port\Steps\StepAggregator->process() /mnt/g/Projects/scratches/arraytocsv/test.php:41
0.0210 604616 3. Port\Steps\StepAggregator->Port\Steps\{closure}() /mnt/g/Projects/scratches/arraytocsv/vendor/portphp/steps/src/StepAggregator.php:121
0.0210 604616 4. Port\Steps\Step\ValueConverterStep->process() /mnt/g/Projects/scratches/arraytocsv/vendor/portphp/steps/src/StepAggregator.php:178
0.0234 764216 5. Symfony\Component\PropertyAccess\PropertyAccessor->getValue() /mnt/g/Projects/scratches/arraytocsv/vendor/portphp/steps/src/Step/ValueConverterStep.php:40
0.0251 792512 6. Symfony\Component\PropertyAccess\PropertyAccessor->readPropertiesUntil() /mnt/g/Projects/scratches/arraytocsv/vendor/symfony/property-access/PropertyAccessor.php:165
0.0251 792888 7. Symfony\Component\PropertyAccess\PropertyAccessor->readProperty() /mnt/g/Projects/scratches/arraytocsv/vendor/symfony/property-access/PropertyAccessor.php:392
Hi,
I just tried the csv example
but I receive this error