Mathematica Analyzing a text file in mathematica

AI Thread Summary
The discussion revolves around extracting specific data from a large Gaussian log file using Mathematica. The original poster seeks guidance on how to search for strings within the text and assign values to variables. While some participants express doubt about Mathematica being the best tool for this task, they acknowledge its capabilities alongside other programming languages like Python, C, and Perl. A suggestion is made to provide a sample text fragment to clarify the extraction requirements, which would help in formulating a code solution. There is also a conversation about searching strings in Mathematica, with one participant humorously contrasting it with Python's rfind() function, while others explore the feasibility of searching forward through the text to find the last occurrence of a string. Overall, the discussion highlights the challenges of using Mathematica for text parsing and the potential for alternative programming solutions.
raymound
Messages
13
Reaction score
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
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.
 
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
 
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
 
Well, so much for Mathematica being "perfect" for this :-p ...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.
 

Similar threads

Replies
5
Views
2K
Replies
1
Views
9K
Replies
1
Views
6K
Replies
6
Views
11K
Replies
1
Views
7K
Replies
6
Views
10K
Back
Top