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

148
Vistas
Use PHP to break a list at every nth line to create CSV

Per criticism, I have focused the question to PHP, but alternative solutions--including javascript, python, and Excel--are acceptable.

Given the following list how do break it into a tab-delineated csv at every nth record (i.e., 3) ?

Apples
Sweet and juicy, these babies are in season!
$2
Bananas
Packed with essential vitamins, our organic bananas are perfect for a snack!
$1
Peaches
Juicy Georgia peaches are available!
$2
Tomatoes
Our variety is the perfect mix of juicy and hearty for your summer salads!
$1
Cucumbers
These cucumbers pair with tomatoes for amazing salads.
$2

The desired output would be

Apples\tSweet and juicy, these babies are in season!\t$2\n
Bananas\tPacked with essential vitamins, our organic bananas are perfect for a snack!\y$1\n
Peaches\tJuicy Georgia peaches are available!\t$2\n
Tomatoes\tOur variety is the perfect mix of juicy and hearty for your summer salads!\t$1\n
Cucumbers\tThese cucumbers pair with tomatoes for amazing salads.\t$2\n

I have attempted this exercise in SublimeText with regex but cannot master the pattern to match every nth occurrence.

Any solution will do. I just need to parse thousands of records into a spreadsheet.

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