MKuranowski / aiocsv

Python: Asynchronous CSV reading/writing
https://pypi.org/project/aiocsv/
MIT License
67 stars 9 forks source link

No `line_num`? #19

Closed YaraslauZhylko closed 6 months ago

YaraslauZhylko commented 8 months ago

Hi!

Is there a reason why line_num functionality is not implemented for the AsyncReader?

Seems to be as easy as adding self._line_num += 1 to the AsyncReader.__anext__() method.

Are there any less obvious implementation details that I'm missing? :thinking:

MKuranowski commented 8 months ago

This would track record numbers, not line numbers. Records can span multiple lines.

YaraslauZhylko commented 8 months ago

Makes sense.

Still, csv nadles the actual line count inside the reader class. And in aiocsv its functionality is basically replaced by parser/_parser that seem to be aware of the nmbe rfo new lines that got processed to get one record.

Will it be hard to implment the count there?

MKuranowski commented 8 months ago

This should probably be easy to implement, since parser is internal it can just yield line_num, record instead of yield record. I just never been bothered to implement this.

YaraslauZhylko commented 8 months ago

In my particular case I need to report CSV file errors and I need the actual line numner to associate with the error.