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

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