Skip to main content

Timeline for CSV handling class

Current License: CC BY-SA 4.0

5 events
when toggle format what by license comment
Oct 27 at 13:37 comment added Janus Bahs Jacquet “I mean, we prohibit e.g. "foo.csv.gz", fine. The > 2 test makes sense.” — I don’t think it does. Yes, it prohibits foo.csv.gz, but it also prohibits foo.bar.csv or Transactions as of 15.08.2025.csv, which are both perfectly valid file names for a CSV file. Validating a file path/name should not care how many dots the file name has, only whether it ends in .csv (if even that – a file doesn’t need to have any extension at all to be valid CSV).
Oct 26 at 3:51 comment added J_H @STerliakov No, of course not. Clearly we still get an exception raised in such a case. I was trying to preserve at least some of the OP's original design. The OP apparently wanted a "check the path argument" phase, followed by a "read the table rows" phase, perhaps to improve the quality of the diagnostic for what OP believed was a common error like misspelled filename. // I was hoping that a revised codebase might point the way to a streaming rows interface, with smaller memory footprint. As it stands we read all into RAM and return, so no need for a class object. A function suffices.
Oct 25 at 23:51 comment added STerliakov Consider making ValidateFilepath() responsible for verifying the file is readable - are you proposing to introduce a TOCTOU bug right there? fopen can fail, no matter what validations you have performed before - an enemy process could have removed the file or changed its permissions between your validation call and the actual attempt to read the file. This is too common mistake to go unnoticed. Soget_csv cannot be infallible, it should still throw some exception on failure (IDK how exceptions work in PHP, but hopefully you can do that)
Oct 24 at 20:29 history edited J_H CC BY-SA 4.0
added 1 character in body
Oct 24 at 20:24 history answered J_H CC BY-SA 4.0