Skip to main content
corrected a term (register -> record)
Source Link
Vito Vanin
  • 588
  • 2
  • 8

Cases[ ] helps selecting just what we want from a file with many different types of records. First, import the file

file = Import["filename", "Table"] 

define the appropriate pattern

pattern = {_Integer, _Integer, _Real, _Real, _Real} 

and extract the selected registersrecords

u = Cases[file, pattern] 

Sort by the first column

v = SortBy[u, #[[1]] &] 

Sure it can be performed in a single command line

v = SortBy[Cases[file, {_Integer, _Integer, _Real, _Real, _Real}], #[[1]]&][[All, {3, 4, 5}]] 

including also the reduction of the list to the coordinates values.

Cases[ ] helps selecting just what we want from a file with many different types of records. First, import the file

file = Import["filename", "Table"] 

define the appropriate pattern

pattern = {_Integer, _Integer, _Real, _Real, _Real} 

and extract the selected registers

u = Cases[file, pattern] 

Sort by the first column

v = SortBy[u, #[[1]] &] 

Sure it can be performed in a single line

SortBy[Cases[file, {_Integer, _Integer, _Real, _Real, _Real}], #[[1]]&][[All, {3, 4, 5}]] 

including also the reduction of the list to the coordinates values.

Cases[ ] helps selecting just what we want from a file with many different types of records. First, import the file

file = Import["filename", "Table"] 

define the appropriate pattern

pattern = {_Integer, _Integer, _Real, _Real, _Real} 

and extract the selected records

u = Cases[file, pattern] 

Sort by the first column

v = SortBy[u, #[[1]] &] 

Sure it can be performed in a single command line

v = SortBy[Cases[file, {_Integer, _Integer, _Real, _Real, _Real}], #[[1]]&][[All, {3, 4, 5}]] 

including also the reduction of the list to the coordinates values.

Source Link
Vito Vanin
  • 588
  • 2
  • 8

Cases[ ] helps selecting just what we want from a file with many different types of records. First, import the file

file = Import["filename", "Table"] 

define the appropriate pattern

pattern = {_Integer, _Integer, _Real, _Real, _Real} 

and extract the selected registers

u = Cases[file, pattern] 

Sort by the first column

v = SortBy[u, #[[1]] &] 

Sure it can be performed in a single line

SortBy[Cases[file, {_Integer, _Integer, _Real, _Real, _Real}], #[[1]]&][[All, {3, 4, 5}]] 

including also the reduction of the list to the coordinates values.