Getting the count of lines without "using up" the lazy collection #53
Unanswered
ragingdave
asked this question in
Q&A
Replies: 2 comments 1 reply
-
You missed getRows()
|
Beta Was this translation helpful? Give feedback.
1 reply
-
It's definitely been asked twice in the last 4 months, because that's why I'm here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've run into what I would consider a common use case with attempting to get a count of the lines in the file that you might be reading. For example, in a file with >90k lines that could have more or less. I would like to be able to know using a progress bar during processing how many are left/how much longer it'll take.
This seems impossible as once you call
count()
the lazy collection is consumed, and attempting to call any other methods on the collection results in no data as if the file was empty.I'm wondering what if any recourse there might be, if this is potentially more of a laravel LazyCollection issue, or if there are any tips to getting this functionality working at all.
Example:
This example demonstrates the issue of being unable to get the count, and still be able to process. It seems that you can either do one or the other, but not both.
Beta Was this translation helpful? Give feedback.
All reactions