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

265
Views
Angular: forma eficiente de analizar 10000 filas de archivos csv/tsv

Estoy buscando una forma más suficiente (o lib) para analizar csv/tsv que contiene alrededor de 5000 ~ 10000 filas (usándola para representar una tabla con desplazamiento virtual cdk para obtener una vista previa del archivo). Mi implementación actual es bastante banana para esa cantidad de filas.

 this.httpClient.get(this.dataSrc, { headers: { Accept: 'text/plain' }, responseType: 'text' }).subscribe(res => { // handles tsv or csv content const lines = res.split(/\r|\n/); const separator = lines[0].indexOf('\t') !== -1 ? '\t' : ','; this.parsedCSV = lines.map(l => l.split(separator)); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Se ve bien, pero analizar una gran cantidad de datos congelará el hilo. Debe dormir y esperar el hilo para que el analizador no se congele.

Así es como yo lo haría, echa un vistazo.

 const sleep = (msTime) => { return new Promise((resolve, reject) => { setTimeout(() => { resolve(); }, msTime); }); } const parse(csv, onProgress) => { const lineSplitter = RegExp('\r|\n', 'g'); const result = [] var index =0; let match; // split one each time, so the thread won't freeze while ((match = lineSplitter.exec(csv)) !== null) { const line = match[0]; const separator = line.indexOf('\t') !== -1 ? '\t' : ','; result.push(line.split(separator)) if (index % 30 === 0) await sleep(10); // This will make sure the thread won't freeze if (onProgress) await onProgress((index / lines.length) * 100); index++; } return result; }

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!