Re: Mathematica problem - generate filename automatically
- From: Jean-Marc Gulliet <jeanmarc.gulliet@xxxxxxxxx>
- Date: Thu, 20 Sep 2007 14:13:00 +0200
Dave (from the UK) wrote:
Bhuvanesh wrote:
<snip>
Map[(data = Import[#, "Table"]; ListPlot[data, PlotLabel->#])&, filenames]
Is it possible for the PlotLabel to be a be a bit more sophisticated than simply the name of the file. I want a typical PlotLabel to be
"Ref 4A, 1234 MHz, 10\[Degree] to 20\[Degree]"
rather than the just the file name.
<snip>
Sure it can. Mathematica has a large set of string manipulation functions. See
<http://reference.wolfram.com/mathematica/guide/StringManipulation.html>
For instance,
In[1]:= StringJoin["Ref ", StringTake[#, 2], ", ",
StringTake[#, {4, 7}], " MHz, ",
ToString[ToExpression[StringTake[#, {8, 9}]]], "\[Degree] to ",
StringTake[#, {11, 12}], "\[Degree]"] & /@ {"4Af461l00u10.txt",
"4Af461l00u20.txt", "4Af461l00u30.txt"}
Out[1]= {"Ref 4A, 461l MHz, 0\[Degree] to 10\[Degree]", "Ref 4A, 461l MHz, 0\[Degree] to 20\[Degree]", "Ref 4A, 461l MHz, 0\[Degree] to 30\[Degree]"}
(Note that the ASCII string "\[Degree" will display as the degree character when evaluated or pasted in a Mathematica notebook.)
Regards,
--
Jean-Marc
.
- References:
- Mathematica problem - generate filename automatically
- From: Dave (from the UK)
- Re: Mathematica problem - generate filename automatically
- From: Bhuvanesh
- Re: Mathematica problem - generate filename automatically
- From: Dave (from the UK)
- Mathematica problem - generate filename automatically
- Prev by Date: On Mathgroup. was: Re: Mathematica problem - generate filename automatically
- Next by Date: On comp.soft-sys.math.mathematica being moderated [Re: Mathematica problem - generate filename automatically]
- Previous by thread: Re: On Mathgroup. was: Re: Mathematica problem - generate filename automatically
- Next by thread: On comp.soft-sys.math.mathematica being moderated [Re: Mathematica problem - generate filename automatically]
- Index(es):