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

Why does calling getContent() seem to empty the iterator returned by the Reader #522

Closed
justageek opened this issue Apr 4, 2024 · 2 comments

Comments

@justageek
Copy link

(Fill in the relevant information below to help triage your issue.)

Q A
Version 9.15

Question

We are creating a Reader from a stream, using the Laravel storage system, like

$csv = Reader::createFromStream($this->storage->readStream($returnFile));

Then we get the rows from the reader, like

$data = $csv->getRecords();

If we call the following:

$csv->getContent()

before we try to iterate over the rows in $data, the iterator appears to be empty. If we remove the call to getContent(), the iterator is not empty.

I was curious if you know why this is happening?

Checks before submitting

  • [ x] Be sure that there isn't already an issue about this. See: Issues list
  • [ x] Be sure that there isn't already a pull request about this. See: Pull requests
  • [ x] I have read, searched and not found the information on the documentation website.
  • [x ] I have read, searched and not found the information on PHP related forums and/or websites.
  • [ x] This issue is about 1 question around the package with no business or domain specific logic related to a specific situation.
  • [ x] The question has a descriptive title. For example: "Can I use the library with compressed CSV documents ?".
@nyamsprod
Copy link
Member

nyamsprod commented Apr 4, 2024

Hi @justageek and thanks for using the package. On top of my head I do not know since you are using your own stream via createFromStream. Depending on your setup the results may be inline with your configuration.

You should try to see if you can replicate the same behaviour with createFromPath if so then a reproducible script would be handy for further investigations if not then it is definitely a configuration issue of your storage application.

@nyamsprod
Copy link
Member

Will re-open the issue if more information/context is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants