Tag Info

Hot answers tagged

11

It is not straightforward to access the clipboard contents but one way, that doesn't involve writing and reading from temporary notebooks is to use the undocumented ClipboardNotebook function: CellPrint /@ StringSplit[NotebookGet[ClipboardNotebook[]][[1, 1, 1]], "\n"]; See also this answer which mentions some caveats. This prints strings as text cells. ...


11

As suggested by @Jens, HDF5 can be fast imported and manipulated in Mathematica. The performance of importing HDF5 is as efficient as MAT file in Python and you can read only a part of HDF5 file into memory. From the question, Mathematica is about 3~4 times slower in reading MAT files. The speed of reading HDF5 files are very close to the speed in Python. ...


10

The problem is that Mathematica has no concept of using any datatype more specific than Integer or Real, and I think these are (on a 64bit computer) always 64bit long. So I can't think of a way to import that data into Mathematica in a way that would need less memory in the final state. If there is a limit of slightly more than 2GB in the size mma can import ...


10

Just like Albert I recommend using the second argument of Dynamic. Furthermore I recommend that you embrace the first A in AJAX, which stands for "asynchronous", so the kernel isn't busy while it collects the data (this might be why some change events are lost with your code). You can see how well the second argument of Dynamic works with this example: ...


9

I think the standard way to do this is to use the second argument of Dynamic, e.g. like so: With[{ getCompletion = Function[ Import[ "https://maps.googleapis.com/maps/api/geocode/json", "JSON", "RequestParameters" -> {"address" -> #} ] //. {{r__Rule} :> (Association[r])} ]}, DynamicModule[{ addr = "555 Mission St, San ...


7

I would do it this way. I would write a function pasteLines[txt_, styl_] := (CellPrint @ Cell[#, styl] & /@ StringSplit[txt, "\n"];) To use it, I would first write pasteLines["", "Input"] I would line copy the text I wanted from the external editor onto the clipboard and paste it between the quotes in the empty string (1st argument), getting ...


6

JSON stands for JavaScript Object Notation. In JavaScript, and hence in JSON, the ordering of dictionary keys is not determined, and not meaningful. Thus Mathematica's behaviour is correct. From the JavaScript language specification, An Object is an unordered collection of properties. Each property consists of a name, a value and a set of attributes. ...


4

The simplest thing to try would be to just import one sheet at a time. Do you see crashes even when only importing one sheet at a time? If that still crashes I see several things you could try and am not sure which would work best for you: Use .NET/Link and COM You could use .NET/Link to access excel via COM if you are on Windows to do what you want. But ...


3

refering to my answer your other question here is how you can get a table of e.g. coordinates and temperature from your example data (adopt to your needs): url = "http://api.openweathermap.org/data/2.5/find?lat=55.5&lon=37.5&cnt=10"; data = Import[url,"JSON"] //. x : {__Rule} :> Association[x]; Map[ (# @@@ {{"coord","lat"}, {"coord","lon"}, ...


3

You should use either Put or Save depending on what you want. With Put you just save the values of your expression. With Save you save the definition of the symbol. To retrieve the solutions you use Get. See code below In[357]:= s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}] Out[357]= {{y -> InterpolatingFunction[{{0., 30.}}, ...


2

Here is another version of the C code. As I have supposed this should be done much more efficient by avoiding a complete copy of the data I have implemented that to proof my point. The code below can only handle lists of integers (rank 1 arrays), but it reads those with an adjustable buffer size. With this version I could successfully read an integer ...


2

There are a few formatting issues to take care of before you can use the data imported from Excel. Let's start with a simple adjacency matrix: WeightedAdjacencyGraph[ {{∞, 1, ∞}, {∞, ∞, 1}, {1, 1, ∞}} ] which generates the following graph: Let's export that adjacency matrix to an Excel file: Export["adjmat.xlsx", {{∞, 1, ∞}, {∞, ∞, 1}, {1, 1, ∞}}] ...


2

Where possible I try to use ReadList as it is usually quite a bit faster than Import: hex[s_String] := FromDigits[s, 16] ReadList["test.dat", hex[Word], RecordLists -> True] {{15, 27952, 22528, 18048, 14224, 10512, 6992, 3504}, {736, 63216, 60704, 59296, 59088, 4672, 13456, 20048}, {26368, 30320, 31584, 25728, 20800, 16672, 12544, 9120}, {5328, ...


1

The title of your post should be rather something like "Why Import rescales my pdb coordinates ?" The answer is actually in the pdb documentation: Yes, for some reason, when Mma imports a PDB file it automatically converts the atoms coordinates (by default in Angstroms) into picometers, and it explains why you observe a completely different PlotRange ...


1

Here is a way to do what you want in one go. If you put your file names in a list named e.g. files, then the following gives you a list of lists, where each sub-list gives you the "T" value paired with the average of the corresponding "tts" value: getData[files_?(VectorQ[#, StringQ] &)] := Module[{str = ReadList[#, String] & /@ files // Flatten}, ...


1

Here's how I'd do it... Grab all the file names you want from a directory: files = FileNames["*.txt", "directory_here"]; Then apply a function to grab those values... grabdata[filepath_] := Module[{text = Import[filepath, "Table"]}, Thread[Cases[text, {#, num_} :> ToExpression[num]] & /@ {"T=", "tts="}]] grabdata/@files {{1, ...


1

As suggested by @guess I would use Import[..., "Table"] to read in the data as a mixture of strings and numeric values, then use a rule to convert the complex values (with not a For loop in sight!). This method does not require you to know the complex column positions in advance. Firstly I copied and pasted your example data to create a string: stringData ...


1

Using With and CloudDeploy (and an extra Column somehow) will do it: man = With[{data = (* Import[ ... ] *) { {0, 1, 0, 0, 0, 5}, {1, 1, 1, 1, 1, 295}, {1, 2, 0, 1, 1, 5}}}, Manipulate[ Column[{"", ListLinePlot[{Select[ data[[All, {1, 2, 3}]], #[[1]] == Round[bonbedrag] &][[All, {2, 3}]], ...



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