Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda