Message Boards Message Boards

0
|
4526 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Data Import[ ... , "Table" ] do not transpose

Posted 11 years ago

I want to ListPlot the data in my txt file.

In[5]:= data = 
 Import["C:UsersMitjaDocuments

ovaacrocurvature.txt", "Table"]

Out[5]= {{-3726, 5094}, {-3646, 5392}, {-3518, 5490}, {-3278, 
  5723}, {-3163, 5862}, {-2744, 6218}, {-2560, 6283}, {-2037, 
  6570}, {-1872, 6691}, {-1286, 6923}, {-1072, 6940}, {-429, 
  7070}, {-219.4, 7137}, {219.4, 7137}, {429, 7070}, {1072, 
  6940}, {1286, 6923}, {1872, 6691}, {2037, 6570}, {2560, 
  6283}, {2744, 6218}, {3163, 5862}, {3278, 5723}, {3518, 
  5490}, {3646, 5392}, {3726, 5094}, {}}

In[6]:= points = Transpose[{data[[All, 1]], data[[All, 2]]}]

During evaluation of In[6]:= Part::partw: Part 1 of {} does not exist. >>

During evaluation of In[6]:= Part::partw: Part 2 of {} does not exist. >>

During evaluation of In[6]:= Transpose::nmtx: The first two levels of the one-dimensional list {{{-3726,5094},{-3646,5392},{-3518,5490},{-3278,5723},{-3163,5862},{-2744,6218},{-2560,6283},{-2037,6570},{-1872,6691},{-1286,6923},{-1072,6940},{-429,7070},{-219.4,7137},{219.4,7137},{429,7070},{1072,6940},{1286,6923},{1872,6691},{2037,6570},{2560,6283},{2744,6218},{3163,5862},{3278,5723},{3518,5490},{3646,5392},{3726,5094},{}}[[All,1]],{{-3726,5094},{-3646,5392},{-3518,5490},{-3278,5723},{-3163,5862},{-2744,6218},{-2560,6283},{-2037,6570},{-1872,6691},{-1286,6923},{-1072,6940},{-429,7070},{-219.4,7137},{219.4,7137},{429,7070},{1072,6940},{1286,6923},{1872,6691},{2037,6570},{2560,6283},{2744,6218},{3163,5862},{3278,5723},{3518,5490},{3646,5392},{3726,5094},{}}[[All,2]]} cannot be transposed. >>

Out[6]= Transpose[{{{-3726, 5094}, {-3646, 5392}, {-3518, 
     5490}, {-3278, 5723}, {-3163, 5862}, {-2744, 6218}, {-2560, 
     6283}, {-2037, 6570}, {-1872, 6691}, {-1286, 6923}, {-1072, 
     6940}, {-429, 7070}, {-219.4, 7137}, {219.4, 7137}, {429, 
     7070}, {1072, 6940}, {1286, 6923}, {1872, 6691}, {2037, 
     6570}, {2560, 6283}, {2744, 6218}, {3163, 5862}, {3278, 
     5723}, {3518, 5490}, {3646, 5392}, {3726, 5094}, {}}[[All, 
   1]], {{-3726, 5094}, {-3646, 5392}, {-3518, 5490}, {-3278, 
     5723}, {-3163, 5862}, {-2744, 6218}, {-2560, 6283}, {-2037, 
     6570}, {-1872, 6691}, {-1286, 6923}, {-1072, 6940}, {-429, 
     7070}, {-219.4, 7137}, {219.4, 7137}, {429, 7070}, {1072, 
     6940}, {1286, 6923}, {1872, 6691}, {2037, 6570}, {2560, 
     6283}, {2744, 6218}, {3163, 5862}, {3278, 5723}, {3518, 
     5490}, {3646, 5392}, {3726, 5094}, {}}[[All, 2]]}]

It Imports data as Table perfectly, but it does not want to Transpose?... :( WHY?

POSTED BY: Mitja Jan?i?
4 Replies

To get rid of the extraneous {} in your data execute the following:

data=DeleteCases[data,{}]
POSTED BY: David Reiss
Posted 11 years ago

The result of Transpose is that points and data are equal, same structure, same values. Your text file has as extra line in it.

POSTED BY: Douglas Kubler

The Part commands (in data[[All, 1]] and data[[All, 2]]) do not succeed because the last element in data, {}, does not have a first or second part (as the message says).

POSTED BY: Ilian Gachevski

*** Here is the file.

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

Group Abstract Group Abstract