Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplFileObject::fputcsv() expects parameter 1 to be array, object given in SplCSVLoader.php on line 58 #8

Open
brainOut opened this issue Apr 3, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@brainOut
Copy link
Contributor

brainOut commented Apr 3, 2019

If we use the example provided :
https://github.com/kiboko-labs/etl/blob/master/docs/pipeline.md#transform-the-contents-of-a-csv-file-into-another-file-format

<?php

use Kiboko\Component\ETL\Flow\Extractor;
use Kiboko\Component\ETL\Flow\Transformer;
use Kiboko\Component\ETL\Flow\Loader;
use Kiboko\Component\ETL\Pipeline;

$pipeline = new Pipeline\Pipeline(
    new Pipeline\PipelineRunner()
);

$pipeline
    ->extract(new Extractor\SplCSVExtractor(new SplFileObject(__DIR__ . '/input-file.csv', 'r')))
    ->transform(new Transformer\CallableTransformer(function($line) {
        return new Pipeline\GenericBucket([
            'title' => $line['Product name'],
            'identifier' => $line['SKU'],
            'public_price' => $line['Price Incl. Tax'],
        ]);
    }))
    ->load(new Loader\SplCSVLoader(new SplFileObject(__DIR__ . '/output-file.csv', 'w')))
    ->run();

The SplCSVLoader class throws an error due to the type mismatch of the first parameter.
here : https://github.com/kiboko-labs/etl/blob/master/Flow/Loader/SplCSVLoader.php#L58

@brainOut brainOut changed the title Array to String Conversion for SplCSVLoader SplFileObject::fputcsv() expects parameter 1 to be array, object given in SplCSVLoader.php on line 58 Apr 4, 2019
@brainOut brainOut added the bug Something isn't working label Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants