Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Get value after last comma in CSV file in Javascript/HTML

Note: I tried using d3js but I accept any other usage model, getting the expected value any method will be positive for me.

Example to file ./Lista_de_Jogos.csv:

a,b,c,d,e,1
f,g,h,i,j,2

I would always like to collect the last value of the CSV regardless of its size, in this example the value would be:

2

My attempt was:

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.1.1/d3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-fetch@3"></script>

<script>
   function lastvalue() {
      let lastvalue = d3.csv("./Lista_de_Jogos.csv");
      var lastvaluelast = lastvalue.substr(lastvalue.lastIndexOf(',') + 1);
      console.log("Last Value: ", {lastvaluelast})
   }
</script>

But I can't get the return of the value, how should I proceed to receive such value?

I've already searched on stackoverflow and couldn't find an example for Javascript/HTML

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to wait for the promise to resolve. Use then:

function lastvalue() {
    d3.csv("./list.csv").then(result => {
        console.log('result:', result)
        const lastRow = result[result.length - 1]
        console.log('lastRow:', lastRow)
        const lastValue = lastRow[result.columns[result.columns.length - 1]]
        console.log('lastValue:', lastValue)
    });
}

lastvalue()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!