Zend certified PHP/Magento developer

Two sets of XY pairs (four columns); the first increments ‘X’ by 1 at a time; the second increments it by 7. Any way to have their X values match?

These are four columns with over 300 rows. Here are the first few entries of the first (increments X by 1 at a time); and here are the first few of the second (increments X by 7 at a time). I’ll call these columns X1, Y1 and X2, Y2 for convenience

I would like to do two things:

  1. Create three columns using X1, Y1, and Y2, where the values of Y2 are placed only on those rows where X2 would have had data. (so, Y2 has a value at rows 0, 7, 14, but is empty on rows 1-6, 8-13, etc.) Example

  2. Create three columns using X2, Y1, and Y2, where those values of Y1 that would have had a matching entry in X1 but not in X2 are deleted. (so the rows 1-6, 8-13, 15-21, etc. of Y1 are deleted). Example

Any way to do this? I have too many entries to do it manually. Thanks a lot for your time!