Message Boards Message Boards

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

Import and edit .asc data

Posted 11 months ago

Hello! I'm a rookie and I would like to import .ASC file. It's a table with 2 columns separated by a space. I want to separate both (in x and y) and then link them via transpose command. How do I get from the raw data to two separated sets of data? So far my approach has been:

asc = 
  SemanticImport["ref 1.asc" , <|1 -> Automatic|>, 
   "List", ExcludedLines -> Range[1, 56], Delimiters -> " "];

The output is:

{"4000.000000   99.579746", "3999.000000  99.571567", "3998.000000 
99.565144", "3997.000000    99.563823", "3996.000000   99.567302", 
"3995.000000    99.572190", "3994.000000   99.574877", "3993.000000  
99.573919", "3992.000000    99.570546", "3991.000000   99.567511", 
"3990.000000    99.567216", "3989.000000   99.570202", "3988.000000  
99.575037", "3987.000000    99.579679", "3986.000000   99.583246", 
"3985.000000    99.586611", ...

and so on

POSTED BY: D S
2 Replies
Posted 11 months ago

Using the example provided (ignoring the \ characters)

importData = {"4000.000000 99.579746", "3999.000000 99.571567", 
   "3998.000000 99.565144", "3997.000000 99.563823", 
   "3996.000000 99.567302", "3995.000000 99.572190", 
   "3994.000000 99.574877", "3993.000000 99.573919", 
   "3992.000000 99.570546", "3991.000000 99.567511", 
   "3990.000000 99.567216", "3989.000000 99.570202", 
   "3988.000000 99.575037", "3987.000000 99.579679", 
   "3986.000000 99.583246", "3985.000000 99.586611"};

data = importData // Map[StringSplit/*ToExpression];

ListLinePlot[data]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 11 months ago

I have found a way (for the first line exemplary):

ToExpression[StringSplit[asc[[1]]][[1]]]

And then I can extract the data via a table.

POSTED BY: D S
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