troubleshooting Question

How to split a csv file in PHP?

Avatar of kenjaW
kenjaW asked on
PHP
2 Comments1 Solution1834 ViewsLast Modified:
I've got a large csv file that I'm creating using php.  At the end of the script, I have a single variable that contains the entire csv file contents (less the header which I have in a separate variable).  I want to run the csv file variable through a splitter that will break down the file into chunks of N lines.  I upload the files and am file size limited.  Obviously, I'd need to split the file after a /r/n so it breaks at the end of a line.  

I'd ultimately like a function that looks something like this:

$csv_array=split_csv($num_lines, $input_csv_file, $csv_header);

but if someone can get me on the right track, I'm happy to code it up and share it.  

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros