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

236
Vistas
Read and extract parameters from a file using NodeJS

I am writing a parser that takes a text file and returns an object. The file looks like this:

Val1 3 x 1 - i
0 t
has
Val2 2 r hgs * i
0 t

Now the information comes in groups of lines. First, the first 3 lines, second, the next 2 lines. This I'd be able to tell how many lines the group has from some data (say numbers 2, 3 in the first line of each group).

The result would be:

result = {Val1:{p1:v1, p2:v2}, Val2:{...}}

Where none of the Val<X> keys would be repeated in the source file.

I've written a simple code that would do this, this is just the basic scheme:

const file = fs.readFileSync(path); //array buffer
const arr = file.toString('utf8').split('\n')

And then I iterate over the array.

Now this program will send information from server back the client browser so it should run reasonably fast.

Is this a fast technique that you'd use? Or is there some other built-in way that would be faster?

about 4 years ago · Juan Pablo Isaza
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