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

233
Views
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
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!