By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Remove last row from csv file using PHP

P: 1
Is it possible to remove the last row of the downloaded csv file, and the removed row will gets added in next sheet. May I know is this possible in PHP. As I searched in google and I didnt find any solutions.
Jun 14 '19 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,298
what exactly do you mean with 'next sheet' - removing a line from a file is relatively easy and could be done in different ways - personally i would probably use the file-method so i would have the lines in an array already. now you can do with it whatever you want - like deleting the original file and write all except the last line back to a file and then put the last line wherever you want to.

PS: note - it will split the lines at newline characters - so if the values in a csv line contain such then it might be necessary to use another method like fgetcsv or such.
Jun 14 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.