Jump to content

Remapping using php and csv files


makenoiz

Recommended Posts

I'm an intermediate php coder however I have a new situation. I need to do some remapping of categories from CSV files we get from our supplier for our php ecommerce store. We use mySQL back end.

We are importing data from a Supplier and need to remap the category names for our online store. There are 16,000 entries in the CSV file.

 

This is what I need to do.

 

1) grab the CSV from the suppliers (from their ftp location)

2) remap the suppliers category names on the acquired CSV to our stores category names. I can either create a new table with the category name relation ships (probably best?) or read my mapping CSV ?

3) save the new CSV to our server where our auto import program can grab it.

 

Eventually, Id like a cron to run the new script but for now Ill do it manually during testing period.

 

 

Thats it! but... as simple as it sounds, I dont know how to start this.

 

Below is an example of what needs to be dont just to clarify.

 

PHP Code:

Our Category(A)      |  Their Category(B)    |    Product ©  |  Product Cat (D)      |  New Product Cat (E)

1. dog/leash/long    |    Pet/walking          |        Item A        |    Pet/sleeping|bed    ** This is what we need to get**

2. dog/leash|long    |    Pet/walking          |      Item B          |    Pet/walking

3. dog/leash|long    |    Pet/sleeping bed    |      Item C      |    Pet/walking

Here is my pseudo code:

for each value in Column D (run the test on each value in Column D)
  for each value in B as i ( check each value in Column B)
     if B(i) = D1 then E1 =A(i)
  end for
end for

 

The new path in this example for Item A would be A3 and would be written to E1.

 

I have 15,000 entries to do.

 

Thank you for any help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.