GratefullyDyed

Q: Making Column Information Turn into Extra Rows

Hello!

 

I am on the newest version of Numbers and I am using it to transfer CSV product information from my etsy shop to my shopify store www.GratefullyDyed.com

 

Image information from etsy export leaves 1 row per product and creates another column for image #2, #3, etc. However, Shopify needs a separate row for each additional image. So, if product "t-shirt-2" has 3 images this is how it would need to look and how it looks in the export CSV I am given:

 

Screen Shot 2016-08-21 at 6.48.10 PM.png

 

 

So, I would need to drop down column "image URL 2" and "image URL 3" to be in column "image URL 1" with the same handle as them. If anyone knows a way to achieve this with some ease it would be appreciated. I have hundreds of products to do this with.

 

Thanks!

iMac (Retina 5K, 27-inch, Late 2015), OS X El Capitan (10.11.6)

Posted on Aug 21, 2016 5:53 PM

Close

Q: Making Column Information Turn into Extra Rows

  • All replies
  • Helpful answers

  • by SGIII,

    SGIII SGIII Aug 22, 2016 9:09 AM in response to GratefullyDyed
    Level 6 (10,796 points)
    Mac OS X
    Aug 22, 2016 9:09 AM in response to GratefullyDyed

    Assuming you have successfully brought the Etsy data into a Numbers table, I think a script is the best way to accomplish something like this:

     

    Screen Shot 2016-08-22 at 12.02.14 PM.png

     

     

    You don't have to know AppleScript to use the script.  You'll know within less than a minute whether it's working for you.  (If you have never run AppleScript on your machine you may need to select the checkmark by Numbers.app at System Preferences > Security & Privacy > Privacy > Accessibility.)

     

    1. Copy-paste script below into Script Editor (in Applications > Utilities).
    2. Click once in the table containing the Etsy data.
    3. Click the triangle 'run' button in Script Editor.
    4. Click once in an "upper left" cell in an existing destination table.
    5. Command-v to paste values.

     

    SG

     

     

    set numColsToExport to 3 -- the number of columns wanted in output

    set outLst to {} -- start a new empty list

     

    --put values from table into list of lists

    tell application "Numbers" to tell front document's active sheet

      tell (first table whose selection range's class is range)

      set vv to (rows whose first cell's value is not missing value)'s cells's value

      end tell

    end tell

     

    -- process the list of lists row by row

    repeat with r from 1 to vv's length

      set thisRow to vv's item r

      set {repeatVals, rowVals} to {{}, {}} -- empty lists to start each row

      repeat with i from 1 to vv's first item's length

      if i < numColsToExport then

      copy thisRow's item i to repeatVals's end

      copy thisRow's item i to rowVals's end

      else if i = numColsToExport then

      copy thisRow's item i to rowVals's end

      copy rowVals to outLst's end

      else

      if r is not 1 and thisRow's item i is not missing value then ¬

      copy repeatVals & thisRow's item i to outLst's end

      end if

      end repeat

    end repeat

     

    -- place result on clipboard for pasting into Numbers

    set pasteStr to ""

    set text item delimiters to tab

    repeat with j in outLst's items

      set pasteStr to pasteStr & j & return

    end repeat

    set the clipboard to pasteStr

     

    --return pasteStr -- uncomment this line for testing