Analyzing a text file in mathematica

In summary, the conversation discusses the need to extract data from a big text file using Mathematica. The speaker is looking for ideas on how to search for specific strings in the text and put their values into a variable. They also mention possibly using other programming languages like Python and suggest using the rfind() function. The conversation ends with a suggestion to search forwards from the beginning until reaching the last position of interest.
  • #1
raymound
13
0
hi,
I have a big text file which includes lots of text and data (gaussian log file (it's a scan file))
and I need to extract some data from it.
so I need mathematica to search along the textual data and find some strings and put the value in front of that string into a variable.
can you gimme some ideas how to do that, I have never worked with mathematica on textual data
 
Physics news on Phys.org
  • #2
any particular reason why you say you "need mathematica" to search this text data file?

I have never used mathematica, but I doubt is the best choice for parsing a text file.

I am sure it can be done with mathematica and C and Fortran and Perl and sed and awk...but I this point in my life I would use Python.
 
  • #3
raymound said:
I have a big text file which includes lots of text and data (gaussian log file (it's a scan file))
and I need to extract some data from it.
so I need mathematica to search along the textual data and find some strings and put the value in front of that string into a variable.

Post a small example fragment of text, possibly even that you have made up, which is an excellent example of the thing you need to search through. Describe exactly what you want to accomplish with that. Make the example good enough that anyone reasonably skilled would not be able to misunderstand what they were supposed to do, even without needing to ask you more questions and without finishing the project only to discover when giving it back to you to get "well that isn't what I wanted to do, how about this different question."

With that it should be feasible to write a few lines of code to accomplish your task
 
  • #4
I almost did the whole thing and mathematica is perfect for this purpose
I just can't find out how can I tell mathematica to search for a string backward from the current position
if you guys can help
I'll be grateful
 
  • #5
Well, so much for Mathematica being "perfect" for this :tongue: ...in python, this is done with rfind() :biggrin:

In Mathematica...can you just simply search forwards, from the beginning, several times until you get to the last position of interest and then pick the occurrence of the string with the largest index?

Like I said, I don't Mathematica...just throwing ideas.
 

1. What is Mathematica and how is it used for text file analysis?

Mathematica is a computational software program commonly used in scientific and mathematical fields. It can also be used for text file analysis by utilizing its built-in functions for data manipulation and visualization.

2. How do you import a text file into Mathematica?

To import a text file into Mathematica, you can use the Import function and specify the file name and format. For example, if your text file is named "data.txt", you can use the code Import["data.txt", "Text"] to import the file.

3. Can Mathematica analyze large text files?

Yes, Mathematica has the capability to analyze large text files. It has efficient memory management and can handle large datasets without any issues. However, the speed of analysis may vary depending on the complexity of the data and the computation power of your computer.

4. How can Mathematica be used for text file cleaning and preprocessing?

Mathematica has various built-in functions for data cleaning and preprocessing, such as StringReplace, StringDelete, and ToLowerCase. These functions can be used to remove unwanted characters, convert text to lowercase, and perform other necessary data cleaning tasks.

5. Can Mathematica perform statistical analysis on text files?

Yes, Mathematica has a wide range of statistical functions that can be applied to text data. These functions can help analyze the frequency of words, identify patterns, and perform other statistical analyses to gain insights from the text file.

Similar threads

  • Programming and Computer Science
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Programming and Computer Science
Replies
1
Views
529
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Programming and Computer Science
2
Replies
65
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
9K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Programming and Computer Science
2
Replies
41
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
11K
Back
Top