MySQL Forums
Forum List  »  Newbie

Re: Help using MySQL reformatting data
Posted by: Zach Ellis
Date: October 03, 2023 07:51PM


edit my bad got a little trigger happy
you can drop the columns with all the skus numbers leaving the state, city, convenient store columns then export those three columns that still have the data as a csv then when you have the product table done add in the foreign key column from the product table into the csv as the fourth column then load it back into the revised table.

that wouldn't work you would still have to make new rows in the csv file manually.

you would have to create a script that uses the old structure data(thats exported into a csv) that loops through each row and have it create a new row for each sku item that is present in that store copying the state city and convinient store columns data from that row and inserting the present product id that matches the new product table.

so for example State - city - convinient store - chocolate_sku - strawberry_sku - cookiescream_sku

NY - New York - store_1 - 1 - 0 - 1
that row goes through the script the results would be in a new csv file

NY - New York - store_1 - 5 would be the id for chocolate_sku in the new product table same for the other two rows
NY - New York - store_1 - 2
NY - New York - store_1 - 6

will give this one a try i will have to revisit python and how to use it to work with csv files.

Zach Ellis

Options: ReplyQuote

Written By
Re: Help using MySQL reformatting data
October 03, 2023 07:51PM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.