Hot answers tagged

7

To whom it may concern, a workaround: path = FileNameJoin[{$HomeDirectory, "Desktop", "testWorking.nb"}]; nb = Notebook[{}, Saveable -> False, NotebookEventActions -> {{"MenuCommand", "Save"} :> {}} (*the fix*) ]; Export[path, nb, "NB"]


5

How about: Export[ StringDrop[path, -2] <> "txt", StringRiffle[ NotebookImport[path, "Input" -> "InputText"], "\n" ] ]


5

There are two issues here: How to write a string that contains a quotation within it, when the quotation mark is what signifies to the system when a string begins and ends. How to export strings with special characters, and have them written in their escaped form: \[Alpha] and not α For the first, you need to construct the string using \" to begin and ...


5

You can also use WriteLine. Update. I added RunnyKine's solution for completeness. Little benchmark: list = ToString /@ RandomReal[{0, 1}, 1000000]; writeList[name_, list_] := Module[{file}, file = OpenWrite[name]; WriteLine[file, #] & /@ list; Close[file] ]; writeList2[name_, list_] := Module[{file}, file = OpenWrite[name, ...


4

Export["file.txt", list, "List"] and Export["file.txt", StringRiffle[list, "\n"], "Text"] both give a text file like hello world other line


4

I agree on two counts: X3D is a logical export format, but Mathematica's X3D support is, at best, limited. Fortunately, the correspondence between Mathematica's GraphicsComplex and X3D is close enough that it is quite easy to roll your own exporter. To do so, let's begin with your own plot. We'll then extract out the primitives and directives that are ...


4

On MMA 10.3 on OSX 10.10.5 I get the same behaviour as @chuy - blunt on the front end and both export formats. I think the implementation is kind of buggy as one might expect the option JoinForm -> "Miter" to solve the problem, however it changes nothing. However, using the additional option JoinForm -> {"Miter",d} does create the desired behaviour ...


3

The .NB files with implementations of the FrontEnd export options Dialogs are located in the folder FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "SystemResources"}] For example, the "PDF Options" Dialog is in the file "ExportPDF.nb". You can open it with a text editor and inspect the implementation. From the internals of the ...


3

Convert the string to a list of integers using ToCharacterCode, and then convert back using FromCharacterCode. testvalsnodvar = {"VOL_FRACTION01"}; Export["test.nc", {"vals_nod_var" -> ToCharacterCode@testvalsnodvar}, "NetCDF"] (* "test.nc" *) Import[ "test.nc", {"Datasets", "vals_nod_var"}] // FromCharacterCode (* {"VOL_FRACTION01"} *)


2

ClearAll[foo] foo = RawBoxes[Replace[ToBoxes@#, InterpretationBox[a_, b_, c___] :> With[{aa = StringReplace[a, { "Sqrt" -> "sqrt", "Power(E," -> "exp(", "Power" -> "pow"}]}, aa], {0, Infinity}]] &; foo@CForm[D[f, M]]


2

Let's say this is your CSV file, http://i.imgur.com/8giNhRb.jpg, penguins http://i.imgur.com/ZQXCY7c.jpg, penguins http://i.imgur.com/bQ6lqNU.jpg, penguins http://i.imgur.com/lxzTgH9.jpg, penguins http://i.imgur.com/eHdgXnt.jpg, penguins http://i.imgur.com/Bmy54vW.jpg, penguins http://i.imgur.com/MtzebxR.jpg, penguins http://i.imgur.com/pkDhR1w.jpg, ...


2

This ListA = { {{n1, p1, a1}, {n1, p2, a2}, {n1, p3, a3}, {n1, p4, a4}}, {{n2, p1, b1}, {n2, p2, b2}, {n2, p3, b3}, {n2, p4, b4}}, {{n3, p1, c1}, {n3, p2, c2}, {n3, p3, c3}, {n3, p4, c4}}}; Export["MathematicaData.CSV", Transpose[Map[Last, ListA, {2}]]] gives this a1,b1,c1,f1 a2,b2,c2,f2 a3,b3,c3,f3 a4,b4,c4,f4 in your csv file. Note you are ...


2

Update Export["filename.csv", ArrayFlatten[{{0, {list[[1, All, 2]]}}, {List /@ list[[All, 1, 1]], list[[All, All, 3]]}}]] OP I'm assuming all the ns and ps are integers. In that case, do Export["filename.csv", SparseArray[{#1, #2} -> #3 & @@@ Flatten[list, 1]]] This works for the ns and ps in any order. If they are actually in the correct ...


2

I felt like it is something very fundamental for working with UI developement in MMA so I asked WRI Support to help me. It took a while but I received a very good answer, which is to suspend DynamicUpdating when Export takes place. [...] For the effect you want, turn off the global DynamicUpdating option for the fronend just before the call to ...


2

The output variable lives on the main kernel. This variable is special, it represents an open file. It cannot be used on the parallel kernels if the file was opened on the main kernel. Is it still possible to write to the same file in parallel from multiple different kernels? Yes, but to do it robustly you must use an advanced parallel programming ...


1

Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]; iii = sol[[1, 14, 0]]; coords = InterpolatingFunctionCoordinates[iii]; valus = InterpolatingFunctionValuesOnGrid[iii];


1

Hope it's not too late... Suppose you want to dump new data (called here "datanew" and generated somehow) into a new sheet of an existing Excel file named "oldfile.xlsx" containing (in sheet 1) data ("dataold"). What I do is: SetDirectory[NotebookDirectory[]] dataold=Import["oldfile.xlsx"] Export["oldfile.xlsx",{dataold,datanew}] What you are doing is ...


1

As pointed out by Ivan Sterling, you cannot simply restrict the PlotRange, as this will not be respected when exporting to "STL". Take Louis's example, ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, PlotRange -> {{0, π}, {0, π}, All}] Export["test.stl", %] // Import One method to make sure ...


1

ClearAll["Global`*"] SetDirectory@NotebookDirectory[] /Users/xxxxxx/Desktop/yxc points = Table[{x, Sin[x]}, {x, Range[0, 2 \[Pi], .01]}]; ListLinePlot[points] Export["Export_Values_1.dat", points] "Export_Values_1.dat" myTable = Table[{r, f3}, {r, 0, 16, 0.1}] ...



Only top voted, non community-wiki answers of a minimum length are eligible