Thanks to visit codestin.com
Credit goes to github.com

Skip to content

export to csv example throws an error #108

@ioweb-gr

Description

@ioweb-gr

Hi,
I just tried the csv example

<?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();

but I receive this error

    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


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions