Message Boards Message Boards

Import and Plot the following data in a .txt file?

Posted 5 years ago

Good night, this question is made because although the existing different post about this thematic, I have not been able to put it into practice. In this moment I have taken measurements of an experiment but I could not visualize them in Mathematica.

Attached a source code of my notebook, and the data in question. Thanks for your attention.

POSTED BY: Harold Medina
4 Replies
Posted 5 years ago
Posted 5 years ago

The same can be done with Import. Try:

data = Import["../RespuestaEscalon_A10_k_1.txt", {"TSV", "Data", All, 1 ;; 2}, "NumberPoint" -> ","]
POSTED BY: Sean Cheren
Posted 5 years ago

Thanks so much, this does work, i had not idea that in this format the "," and the ".", generating a problem in my plot design. Again thanks so much for you time and dedication in my question.

Attachment

Attachments:
POSTED BY: Harold Medina

The first step could be to import the file into Mathematica in TSV format and then clean it up a little:

data = Import[
   ".../RespuestaEscalon_A10_k_1.txt",
    "TSV"];
cleanedData = 
  data /. str_String :> ToExpression@StringReplace[str, "," -> "."];
ListPlot[cleanedData[[All, 1 ;; 2]]]

There may be a faster way with SemanticImport, but the default settings do not give directly usable results.

POSTED BY: Gianluca Gorni
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