Tag Info

New answers tagged

5

Put[OutputForm[outString], "testOut.txt"] compare with Put[outString, "testOut0.txt"] Alternatively, you can use Export: Export["testOut2.txt", outString] (* or Export["testOut2.txt", outString, "Text"] *) or, WriteStream (thanks: Mr.Wizard) strm = OpenWrite["testOut2.txt"]; WriteString[strm, outString] Close[strm] to get the same result:


0

You could cheat by first importing the data and putting them in a list and when you are finished then you join the list with Join. it could look like this: prevData = Import["C:\\Users\\Alex\\Desktop\\1\\file1.nb"]; testData = RandomReal[{0, 1}, {1, 1}]; TestDate = Join[prevData, testData]; Export["C:\\Users\\Alex\\Desktop\\1\\file1.nb", testData];


10

FindFile will tell you which file will be loaded when you ask for a particular package with the backtick syntax. DirectoryName will return the directory that contains a file. Example: In[1]:= FindFile["Combinatorica`"] Out[1]= "/Applications/Mathematica 10.1.app/Contents/AddOns/Packages/Combinatorica/Kernel/init.m" Update: This solution is probably ...


1

I am happy to say this is finally fixed in 10.1. Now Save As will open popup window that points to the folder where the notebook is located and not to where the last directory used or visited. Now no more files will be overwritten and lost. good job WRI


1

CreateDirectory returns the name of the parent directory as Capital litter data = CreateDirectory[folder] (*"C:\\something"*) When you try to use Equal or similar, it done' know anything about the folder but it compares values in hand. Defiantly "c:\\something" dose not equal "C:\\something" because the "c" does not equal "C". To get what you want use : ...


5

CreateDirectory does not return what was input, but the full path to the directory created: Try: SetDirectory["C:\\Temp"]; CreateDirectory["abcdefg12345"] (* C:\\Temp\\abcdefg12345 *) In your case, the difference is between the lowercase "c" and the returned uppercase "C", so the comparison fails for that reason.


3

I believe your general concern is largely unfounded as file caching is already used. Compare these timings performed in Mathematica 10.0.2: Quit[] (* fresh Kernel session *) FileHash["file.mx", #] & /@ {"MD5"} // AbsoluteTiming {0.422024, {258141117636363265815580588062419660198}} FileHash["file.mx", "MD5"] // AbsoluteTiming {0.090005, ...


3

You need to import as "String", not "Binary". The latter returns a list of numbers, which is not exactly the same as the file contents (though there's a one-to-one mapping between the two) ... Think e.g. about the fact that integers in Mathematica can be arbitrarily large while byte values are between 0..255. "String" will return the file contents byte ...



Top 50 recent answers are included