Remapping using php and csv files
Posted: Fri Nov 25, 2011 1:27 pm
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 done just to clarify.
[text]Our Category(A) | Their Category(B) | Product (C) | 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[/text]
Here is my pseudo code:
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
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 done just to clarify.
[text]Our Category(A) | Their Category(B) | Product (C) | 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[/text]
Here is my pseudo code:
Code: Select all
for each value in Column D i=1++(run the test on each value in Column D)
for each value in B i=1++ ( check each value in Column B)
if B(i) = D(i) then E(i) =A(i)
end for
end forThe 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