Using Java Processing I'm trying to find the last time that a specific string value is found in a table column and get another value from the cell next to it. How would I do something like this?
Asked
Active
Viewed 20 times
0
-
Maybe this? https://stackoverflow.com/questions/1468998/execute-sql-on-csv-files-via-jdbc – g00se Apr 10 '22 at 11:50
1 Answers
0
Use any of the several available CSV parsing tools to read your file. For example, Apache Commons CSV.
As you read in each line, test if it contains your target value. If so, remember that row by stashing in a variable. Each time you find a hit, replace the previously stashed value with the latest, storing in that same variable.
When done reading the file, the last row meeting your criteria is in that variable. Now read the adjacent cell from that row. Voilà, your result.
You will find many examples of reading CSV files in existing Questions and Answers. Again, I recommend you use a library for reading and parsing the CSV rather than perform that chore yourself.

Basil Bourque
- 303,325
- 100
- 852
- 1,154