oracle765 Posted January 28, 2014 Share Posted January 28, 2014 I have the following semi colon delimited file, in fact hundreds of them which are all the same format Does PHP have the facility to open this file and split it into 3 separate excel or csv files EG For the OS Machine, Manufacturer, Model, Current User, OS, Version, Install Date DETAILS HERE For the CPU Model, Socket Designation,Status, 3 of Cores, 3 of Logical Processors DETAILS HERE and for the Servicea Service,State,Install Date, Install Path DETAILS HERE Spiltintofiles.txt Quote Link to comment Share on other sites More sharing options...
requinix Posted January 28, 2014 Share Posted January 28, 2014 (edited) Sure it can do that - as long as you tell it how. For each file, 1. Read a line. It'll look like ### LABEL ###. Create and open a handle for whatever file should hold the following contents. 2. Read a line. If the line isn't empty then write it out to whatever file you had opened. Repeat. 3. If the line is empty then close the file and, if you aren't at the end of the file yet, go to step 1. - You can read a line with fgets() but remember that it includes the trailing newline and so you should probably remove it with trim() before you look at it too closely. - fwrite() to write a line. - Check if you're at the end of the file with feof(). Edited January 28, 2014 by requinix Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.