How can I ignore extraneous lines using CSV Crate - Solved

I have been using the CSV Crate to successfully read csv files generated by one of my banks. However, the csv file generated by Fidelity has extraneous lines at the beginning of the file and extraneous lines at the end. Some of these lines are blank. Some have text such as the date/time stamp and other miscellaneous text. The header is always on line 5 and there's a blank line after the last record.

What approach can I take to read only the valid part of the file into the CSV crate?

I don't know if there's a general "sed/awk this Reader for me" crate, but here's a couple quick ad-hoc possibilities.

Thank you! I am slowly digesting your solution (I am learning Rust), but it looks like what I need.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.