Mathematica Mathematica and large data arrays

AI Thread Summary
The discussion revolves around extracting specific columns from an imported Excel dataset in a programming environment. The user successfully imported a dataset with 18 columns and 25 rows, but initially struggled to plot column 2 against column 4 while omitting the first two rows of text. The solution involved using the Part command to extract the desired columns, specifically using syntax like data[[2 ;;, {2, 4}]] for extraction. However, the user encountered issues with plotting, resulting in an empty graph. The problem was traced back to the use of the "FormattedData" option during import, which did not format the numbers correctly for plotting. Removing this option resolved the issue, allowing for successful plotting of the data. The discussion highlights the importance of data formatting in visualization tasks.
jd83605
Messages
3
Reaction score
0
Hi,

I have imported a data set from EXCEL that is 18 columns wide and 25 rows long. Each row of data appears within it own set of brackets as expected. I am able to pull out individual elements of the array. However, I want to plot column 2 vs column 4. How might I extract those two columns of data from my imported data? Moreover, the first two rows are text that I would prefer to omit.

Data format:

{a11,a12,...a118}
{a21,a22,...a218}
.
.
.
{a251,a252,...a2518}

Any help would be appreciated. I cannot find a similar topic at the Wolfram site.

Jim
 
Physics news on Phys.org
The Part[...] command should probably be enough for this. It has the abbreviation [[...]].
Ranges in Part are specified using ;;, so e.g.
list[[4;;10;;2]]
will give you the elements at positions {4,6,8,10}.

Here's an array the same size as your data
data = Array[a, {18, 25}];

To extract the 2nd column you can write
data[[All,2]]
or
Transpose[data][[2]]

To extract the 2nd column without the first element, use
data[[2;;,2]]
or
Transpose[data][[2,2;;]]

To extract the 2nd and 4th column without the first elements use
data[[2 ;;, {2, 4}]]

Then this can be plotted with ListPlot. Eg, here's some random data
data = Accumulate[RandomReal[{0, 1}, {18, 25}]];
which is plotted using
ListPlot[data[[2 ;;, {2, 4}]], Joined -> True, PlotMarkers -> Automatic]
 
Thanks for the input. I was able to extract the data using a variation of what you gave me. However, I cannot make it plot. I simply get a default graph from -1 to 1 on both axes and no data.

Here is what I was able to do.
In[127]:= tmp =
Import["E:/filename.xlsx", "FormattedData"][[1, 3 ;;, {2, 4}]]

Out[127] = {{22.7,-2.95},{22.70,-2.983}...{22.7,-3.09}}

ListPlot[tmp] gives me an empty graph. I have tried playing with DataRange with no success.

as always thanks for any assistance.

Jim
 
I'm not sure why you're getting an empty plot. But the small extract of the data you provided above has the x-values for all terms equal, so you'd be getting a vertical line...
(I removed the dots and plotted it to check - it works fine.)
Maybe use Joined->True option so that you can see the line...
 
It turns out if I remove the "FormattedData" option from the import command ListPlot works fine. Apparently, that option doesn't put the numbers in the approrpiate format.

I truncated the data to make it easier to observe. That is why it appears as a vertical line.

Thanks for your input.
 
Glad you got it sorted!
 

Similar threads

Replies
1
Views
2K
Replies
6
Views
4K
Replies
2
Views
5K
Replies
3
Views
3K
Replies
2
Views
3K
Replies
3
Views
3K
Replies
2
Views
2K
Replies
2
Views
3K
Back
Top