# How to generate a list of datas from a table with more y-values

I try to create a list of data on which I can perfrom a function. But I have problems in getting the data from my Excel sheet. My Excel sheet looks like this:

      x1 y[1,1] y[1,2] y[1,3] y[1,4] .... y[1,200]
x2 y[2,1] y[2,2] y[2,3] y[2,4] .... y[2,200]
...
xn ..


now I would like to get a list

      { {data1}, {data2}, {data3}, ... {data200}}


where

      data1 = {{x1,y[1,1]},{x2,y[2,1]},..}
and
data2 = {{x1,y[1,2]},{x2,y[2,2]},..}
and so on


Can anyone give me an advice how to do it? Thanks a lot Walter

• Did you check Import (and possibly the "Table" option)? – anderstood Mar 14 '17 at 14:44
• @anderstood thanks, but how can I make the list by mapping it with a rule. The x value is the first column and always the same for the different y-values, which are in separate columns – Walter Schrabmair Mar 14 '17 at 14:54
• If you managed to import the data, then your question is about rearranging the imported list and you should probably rewrite your question which is not related to importing nor excel. – anderstood Mar 14 '17 at 15:10
• @anderstood thanks I found it: Table[{s[[i, 1]], s[[1, j]]}, {i, 1, Length[s]}, {j, 2, Length[First@s]}] ' – Walter Schrabmair Mar 14 '17 at 15:18

I am not sure if I understand your question. Say you have imported the following structure:

 import = {{x1, y[1, 1], y[1, 2], y[1, 3]}, {x2, y[2, 1], y[2, 2], y[2, 3]}}


Then, it would probably be more appropriate to save new lists in data[1], data[2], etc. rather than data1, data2, etc. This is how it could be done:

Table[data[i - 1] =
Transpose@{import[[All, 1]], import[[All, i]]}, {i, 2, Length@Transpose@import}]


Then:

 data[1] (* {{x1, y[1, 1]}, {x2, y[2, 1]}} *)
data[2] (* {{x1, y[1, 2]}, {x2, y[2, 2]}} *)


If you really need data1, data2, etc. let me know and I'll add a suggestion.

• Thanks a lot, your solution is much more sophisticated – Walter Schrabmair Mar 14 '17 at 15:19
• @WalterSchrabmair Still, you can improve your question to help future users. – anderstood Mar 14 '17 at 15:33

Given @anderstood's data structure, another way, if you really want to learn about some List Manipulation functions:

data = Transpose[Map[Thread[List[First[#], Rest[#]]&, import]]


The trick here is using List[...] as the function getting threaded between the First element and the list of the Rest of the elements. Map is just the iteration through each row.

Also, this would normally be written like this, where /@ is infix shorthand for Map:

data = Thread[{First[#], Rest[#]}]& /@ import // Transpose

• I am not home to test this for syntax issues, so please help out and correct me :^) I'll check it myself later. – Andrew Cheong Mar 14 '17 at 15:22
• I tested, I think you mean data = Transpose@Map[Thread[List[First[#], Rest[#]]] &, import] (added one closing bracket + Transpose). As per the second line, I think you should add // Transpose afterwards. – anderstood Mar 14 '17 at 15:30
• Ah, thank you @anderson! Will fix. – Andrew Cheong Mar 14 '17 at 15:34
• @AndrewCheong Thanks that was I was wanted to learn, and now I can apply my function to this list of datas, I think by f @@@ {data}` – Walter Schrabmair Mar 14 '17 at 15:53