loop through CSV and update / delete columns

i get a csv every day from a 3rd party stock control system and i need to edit this csv to make the headings and cells match what magento requires to import each row as a valid product.

so i need to loop through this csv with a php while loop and some how target the columns with bad headings and delete those columns.

other columns might just need renaming

some cells might need updating to make their content valid.

the csv gets put to the hosting daily so i have already started to gather some code to get the thing working but am a bit lost now.

i think i just need to get the CSV in an array and then i can do stuff to the array. just not sure how i can edit the array and make it save as a new .CSV

here is what i have: if any one can help it would be appreciated.

p.s the CSV i get from the stock control system is very scruffy: some cols don't have headings when opening in open office but they seem to become new rows when i check the output of my code (from the array dump),

This data set is a mess, and it may take a lot of programming to tease it apart into something useful. For example, the top row of the CSV has 309 columns, but the next row has 590 columns. Not sure what to make of that!

I'll try to give you a code sample that shows the first few columns in a way that will let you address them by name.

Featured Post

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose.
It turns out that Yaho…

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption. Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…