0

I’m rebuilding a customer website using data they stored in excel. The first column has the customer id, the top row contains an item id, and the grid contains the count of the customer and item. Here’s an example

          item_1    item_2    item_3
cust_1    1         2         1
cust_2    0         1         2 

So the problem comes in that the top row is actually the id of the item, and the left first column is the id of the customer. I need to convert this somehow into something I can import into the database. Ideally into a format like this

cust_1, item_1, 1
cust_1, item_2, 2
cust_1, item_3, 1

I have this in an excel spreadsheet

I’ve changed the id fields to be more easily understandable. The left column is actually just a number, not cust_1, the top row is the same thing, just a number.

If this is easier to do in a database I have mysql and sql server available to me. if it’s easier in code I have C# and Python available to me.

Jhorra
  • 6,233
  • 21
  • 69
  • 123
  • Possible duplicate of [Convert matrix to 3-column table ('reverse pivot', 'unpivot', 'flatten', 'normalize')](https://stackoverflow.com/questions/20541905/convert-matrix-to-3-column-table-reverse-pivot-unpivot-flatten-normal) (see second answer) – Slai Jul 30 '19 at 07:28
  • @Slai That link is exactly what I needed. I couldn’t figure out the term to use to describe my excel sheet. – Jhorra Jul 30 '19 at 07:30

0 Answers0