Let me just start by pointing out I'm a new StackExchange user as well as a new Mathematica user (started today!) I mention this as a context to my ineptitude :)
I am attempting to read through a list with the names of files I want to open, import data from them and plot that data. Here is the code I'm trying to use:
testfiles = ({"aspirina.txt", "silicio.txt", "silicio20.txt",
"silicio20luz.txt", "tio2.txt", "vidro.txt", "vidro2.txt"})
Do[{data = Import[path <> ToString[i, StandardForm], {"Table"}],
Print[path <> ToString[i, StandardForm]],
Print[ListLinePlot[data]]}, {i, testfiles}]
(*
Out[500]= {aspirina.txt, silicio.txt, silicio20.txt, silicio20luz.txt,
tio2.txt, vidro.txt, vidro2.txt}
*)
Import::nffil: File not found during Import. >> ~/Desktop/TCOEM/Espetros Raman/aspirina.txt
etc.
The directory and file names are correct, so much so that when I try this directly by just typing the exact same directory I get the desired result.
Firstly, I changed the FormatType setting of ToString[] to StandardForm because the default (OutputForm) would give me an extra whitespace on either side of the full stop in the file names. Why does it do this?
Secondly, why is it that even when Print[] seems to indicate the directory is correct I get the exception saying the file cannot be found during Import?
I specifically did not format the names of the files in the testfiles list individually as strings (using "" around each one) to allow for the case where I have hundreds of such files and just want to copy and paste their names via whatever file manager I happen to be using.
Any help will be greatly appreciated!
StringSplitto break it into individual filenames. – Simon Woods Oct 26 '12 at 14:09