16

Comment This was originally answered on Oct 2, 2012 using V8. The performance can be dramatically improved using V9's URLFetchAsynchronous, as now shown below. Fortunately, we needn't download all the tiles at once. We can use Dynamic to set up a little pan-and-zoom explorer. The first load takes a bit and zooming out takes a bit. Panning and zooming ...


15

Mathematica is not really a reference in digital terrain models, and, there are very powerful software packages to deal with geographical information. But... where would be the fun... If the information in the files includes a digital terrain model (DTM), with the surface of the terrain defined by triangular faces (regular or not), then you can easily ...


12

The documentation is misleading here. On one hand, the only export option is "Append" which can be found under the Options tab. On the other hand, the general documentation reads I really wonder, why it is necessary to put Import only behind an option value when "DataEncoding" isn't an export option at all. Anyway, I have the same behaviour in MacOSX ...


10

Here is a solution for Linux/( ? Mac ? ) uses, or Windows users with a Linux toolkit. To read line 23681 to 23781, use the following variants of head and tail. data=Import["!head -23781 /tmp/data.txt | tail -n 100", "Text"];


9

This should give you back most of your work: code = Import[ "https://bitbucket.org/ricopicone/corruptmathematicanotebook/raw/master/CMN.nb", "NB"]; CreateDocument[ code /. Cell[BoxData[(Graphics3DBox | GraphicsBox)[___]], ___] :> Cell[TextData[ StyleBox["Here was a graphics", FontColor -> RGBColor[1, 0, 0]]], "Text"]]


8

Preface: Since you want to convert other C++ classes to MTensor I have to tell you, that I don't see a possibility for that, because I haven't found how to tell the Wolfram Library to take a chunk of already allocated data and use it for an MTensor. What I do is the other way around. I use the internal data of an MTensor as underlying array for my own ...


8

One workaround is to compress the HDF5 file after it has been exported from Mathematica, using the HDF5 command line tools. Note: on OS X the command line tools can be easily installed using MacPorts using port install h5utils. The command to recompress the data is h5repack -v -f GZIP=1 infile.h5 outfile.h5 This can indeed achieve a significant reduction ...


7

I recently had a similar task decoding 12-bit binary 24-channel electroencephalogram data files and found that bit shifting and masking with BitAnd are the way to go. The specific approach depends on file structure, endianness and channel number. In the case of this 'format 212' binary data file containing two interlaced signals, the following procedure ...


7

If I am not mistaken the 212 format is storing two signals and each 3-byte group provides a 12-bit reading of that pair. Importing with Byte isn't too bad for this set: data = Import["http://physionet.org/physiobank/database/mitdb/100.dat", "Byte"] ~ Partition ~ 3 Then two helpers to parse it: twosComplement[a_, n_] := If[a < 2^(n - 1), a, a - 2^n] ...


7

New solution using RegisterFormat from Wolfram Function Repository: ResourceFunction["RegisterFormat"]["BVH", <|"Extension" -> "bvh"|>] Original Post: Copy/paste from the excellent BVH package by @Sjoerd C. de Vries: The code in this question (Registering/detecting an importer by file name extension) did not work. Neither did the answer. Wolfram ...


6

Import is very well able to handle this format. As a demonstration I use its nephew ImportString to deal with the few lines from your example: data = ImportString[ "28/04/2013 20:01:36.18 2.5013E-2 W 28/04/2013 20:01:36.26 2.5013E-2 W 28/04/2013 20:01:36.32 2.5013E-2 W 28/04/2013 20:01:36.35 2.5011E-2 W 28/04/2013 20:01:36.48 2.5011E-...


6

In version 7 halirutan's export method does not produce a file that is recognized by Import. However, one can write: Export["matrix2.h5.gz", datapourrie, {"GZIP", "HDF5"}] And then: d2 = Import["matrix2.h5.gz", {"Datasets", "/Dataset1"}]; datapourrie == d2 True


6

The MX format (that is written by DumpSave) is not portable between different computer systems. One can't count on it being compatible either between versions, different OSs or different architectures (32 vs 64 bit). I recommend that you use Compress and export the results as a string instead, as I described here. This is not as fast as saving to MX, but ...


6

How about: data = {"0x1", "0xff", "0x1230abde"}; FromDigits[StringTrim[#, "0x"], 16] & /@ data {1, 255, 305179614}


6

data = Table[(i + j) i (i - j), {i, 1, 2}, {j, 1, 22}]; The first step is to define a function to break up each row in the data into lines not exceeded the specified maximum line length. prep[row_, fieldWidth_, lineLength_] := Module[{items = Floor[lineLength/fieldWidth]}, Partition[row, items, items, 1, {}]] The second step is to do the breaking. ...


5

There's no easy way, it's a custom script that assembles the image out of individual slices, and it's written by someone who clearly didn't intend anyone to read it again (including himself). Reverse engineering. The script responsible is http://imgs.xkcd.com/clickdrag/1110.js, the image to be displayed is assembled in line 86 ($image=...). Scanning the ...


5

You can download all the original tiles using the following functions. 404 and file not founds are handled gracefully. I'm avoiding displaying to the FE so as to lower the chances of crashing. url[n1_Integer, d1_String, n2_Integer, d2_String] := "http://imgs.xkcd.com/clickdrag/" <> ToString@n1 <> d1 <> ToString@n2 <> d2 <> ...


5

Change this {x_, y_} -> x + I y to {x_?NumberQ, y_?NumberQ} -> x + I y


5

I just wrote an importer: https://github.com/zbjornson/MYaml. It's built on SnakeYAML and supports all language-independent types. Example 2.10 from the spec: In[1]:= ImportString["--- hr: - Mark McGwire # Following node labeled SS - &SS Sammy Sosa rbi: - *SS # Subsequent occurrence - Ken Griffey", "YAML"] Out[1]= { "hr" ->...


4

It may be those newlines that are messing with you. How about a different approach? data = Import["imag-data.txt", "Table"]~Select~((# != {}) &) ({#1, I #2} & @@@ Drop[data, 1])~Partition~2 (* {{{0.933975, 0. + 2.39067*10^-16 I}, {-0.966082, 0. - 3.66569*10^-16 I}}, {{1.31581, 0. - 3.72881*10^-16 I}, {0.0535199, 0. - 4....


4

Since you requested performance I would avoid Import and DateList and use ReadList and AbsoluteTime. format = {Number, Character, Number, Character, Number, Number, Character, Number, Character, Number, Number, Word}; data = {AbsoluteTime[{#5, #3, #1, #6, #8, #10}], ##11} & @@@ ReadList["data.txt", format]; "data.txt" is of course your data file. ...


4

I would convert your file first to CSV format. Then, there are a number of options for importing CSV files. If Import is too slow, you can try something similar to what is described here or here. The method described in the former link may require custom code, while the first method of the two described in the latter link is quite general and should work ...


4

Carl has shown a way to write to the file what you want, but I would suggest to not even put the terms= into the file: you can read the expression and set it to a variable when reading it. It will also get rid of all kinds of complications that occure if you want to write partially evaluated expressions. This approach lets you choose the name of the variable ...


4

According to the comments you have several options: Use Import and Export to work with Excel files (noted: this is not straightforward with problems mentioned in the comments). Use this answer to manipulate the Excel file like it is done in VB. Using Leonid's SQL DSL as a way to get database like syntax while keeping all the data in Mathematica lists. I ...


4

For large files using ReadList is the way to go. So if we assume the name of your file is "file.txt", then the following should be efficient: StringReplace[#, {"e" -> "*^", "j" -> "I"}] & /@ ReadList["file.txt", Word, WordSeparators -> {"(", ")", " "}, RecordLists -> True] // ToExpression


4

I wrote such a cross-platform tool to convert other formats to wolfram format: WolframExchange Usage wex in.yml # check file but no output wex in.yml -t # output only text wex in.yml -c # output only binary wex in.yml -ct # output both text and binary Result


4

I confirm the issue in Version 9.0.1.0 (Windows 8 64-bit). A workaround is wrapping NumberForm with OutputForm: t2b = Table[{i, OutputForm[NumberForm[Range[i + #], {2, 2}]] & /@ Range[2]}, {i, 1, 2}] Export["tryb.dat", t2b]; FilePrint["tryb.dat" ]


3

I did a little digging, and I do not believe you can access an MDB file using DatabaseLink` on anything but Windows. Looking at the available drivers Needs["DatabaseLink`"] JDBCDriverNames[] (* {"Microsoft Access(ODBC)", "hsqldb", "HSQL(Memory)", "HSQL(Server)", "HSQL(Server+TLS)", "HSQL(Standalone)", "HSQL(Webserver)", "HSQL(Webserver+TLS)", "...


3

As @R.M. said in the comment, the function Put places the file into the directory returned by Directory[]. This location can be changed by using the function SetDirectory. I do not know of a way to directly write the expression terms=OutputFromOtherNotebook into Terms.m using Put, but I do have a method using the function Write. The following code writes ...


3

Depending on your needs it may be helpful to know that a significant amount of time is spent converting a Graphics expression to output Box forms. Example: graphics = Import["http://exampledata.wolfram.com/usamap.zip", "Graphics"]; Timing[cell = Cell[BoxData@ToBoxes@graphics, "Output"];] {1.466, Null} It is now significantly faster to print this pre-...


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