I've got a csv file with column headers. What I'm looking for is, that how can I take out the number from column no. 9 (currency amount) from only those rows, which contain "XYZxxxx" code in the 2nd column and add them up with only the same kind of currency specified in col no. 10?
My approach until now is:
- Parse the content of csv into php array.
- Explode the content into different rows.
- Check for rows containing "XYZxxxx".
Then I cannot figure out, how to take the amount of currency and the type of currency out from these and sum the up with the same type.
I'm thinking that I can look separately for "EUR", "GBP" & "USD" values and group the rows into different variables based on the results, but is it a correct approach or am I overthinking it?