[SOLVED] Code advice for "Range" (example code works, but looks messy)

I am building some coupon code functionality, that displays coupons under specific sections of the page depending on its type. The coupons are managed in a Google Sheet.

I have a fully working set of code, but I am wondering if there is a better way to code it (i.e. simplify the code).

The code is below. Essentially, If there are no coupons in a section, then the header does not get displayed. Then the coupons are shown (it checks the sheet for company, and type) - The company is set in the page Params.

The sheet sep, and url are set as site params. Like, I said, this code does work, but it seems very clumsy to me, and wondering if I can improve it a little.

{{ range $i, $r := getCSV .Site.Params.sep .Site.Params.couponsheet }}
{{ if eq (index $r 0) $.Params.company }}
{{ if eq (index $r 3) "other" }}
**{{ if ne ( index $r 0 ) "" }}**    // Not needed. see edit comment below.
<h2>Other Coupons & Deals</h2>
**{{end}}**
{{end}}
{{ end }}
{{end}}

{{ range $i, $r := getCSV .Site.Params.sep .Site.Params.couponsheet }}
{{ if eq (index $r 0) $.Params.company }}
{{ if eq (index $r 3) "other" }}
<p>{{ index $r 0 }} - {{ index $r 8 }}</p>
{{end}}
{{end}}
{{ end }}

Edit: It seems I don’t actually need the “ne” query for the header which I have starred in the above example. This makes sense as if there are no entries it can’t equal “other” in that example.

Edit 2: This method may create a lot of queries for the build, when I have all the data added. I am forming my data so I can remove the headings, and just list them all in one go. This will make it have 1 range through the data, instead of about 10 (for each page).

Ignore this. I am going the simplified route I mentioned in my edit 2, above.