Group Abstract Group Abstract

Message Boards Message Boards

3
|
5.8K Views
|
6 Replies
|
11 Total Likes
View groups...
Share
Share this post:

How do I extract new lists from given lists?

Posted 4 years ago

Hi,

I have four lists like this :

enter image description here How do I have the final lists for list A, list B, list C, and list D as follow:

listAfinal = {28, 35, 40, 43, 44};

listBfinal = {20, 28, 35, 40, 43};

listCfinal = {18, 20, 28, 35, 40};

listDfinal = {13, 18, 20, 28, 35};
POSTED BY: Alex Teymouri
6 Replies
Posted 4 years ago

Hi Alex,

If the spreadsheet is the source of the data then you can generate the final lists like this. I created the attached AlexData.xlsx for testing.

{listAfinal, listBfinal, listCfinal, listDfinal} = 
  Import["~/Downloads/AlexData.xlsx", {"Data", 1, 5 ;; 9, 2 ;; 5}] // Transpose // Reverse;

{listAfinal, listBfinal, listCfinal, listDfinal} // Column
(*
{28.,35.,40.,43.,44.}
{20.,28.,35.,40.,43.}
{18.,20.,28.,35.,40.}
{13.,18.,20.,28.,35.}
*)
Attachments:
POSTED BY: Rohit Namjoshi

Does the code I attached help?

It should with a large spreadsheet.

POSTED BY: John Baxter

Hi Alex, try:

{listAfinal, listBfinal, listCfinal, listDfinal} = #[[4 ;; 8]] & /@ {listA, listB, listC, listD};

or

{listAfinal, listBfinal, listCfinal, listDfinal} = {listA, listB, listC, listD}[[All, 4 ;; 8]];
POSTED BY: Henrik Schachner
Posted 4 years ago

Thank you so much, Henrik.

Is there any simple command for extracting list B, list C, and list D from list A?

My main list A has about 14000 elements.

POSTED BY: Alex Teymouri

Alex, is it simply this you want?

listB = Prepend[listA, ""];
listC = Prepend[listB, ""];
listD = Prepend[listC, ""];
POSTED BY: Henrik Schachner
Posted 4 years ago

Thank you so much, Henrik, Rohit and John.

You are great men.

POSTED BY: Alex Teymouri
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard