Tag Info

Hot answers tagged

17

Get all the files here: http://JeremyThompson.net/Rocks/Mathematica/MmaWord.zip .Net Mathematica Word Library You will need to use a Microsoft library to open word documents. In a language such as .Net it is very easy; just open Visual Studio, reference the Microsoft.Office.Interop.Word .Net DLL (for Words) and the C:\Program Files\Open XML ...


7

Taking user5601's suggestion to do a little demo, I quickly whipped this up as an example of ProcessLink being used to do non-trivial communication between Mathematica and an external program, but with much less ceremony than using ProcessLink or MathLink. Let's take this little Go program: package main import "net/http" import "bufio" import "os" import ...


6

Both have advantages and disadvantages. Importing XLS is done using a Java-based application. In my experience, it is terribly slow and eats up enormous amounts of memory to the extent that it blows up your Java heap space, requiring a manual adjustment of this heap space (quite often to no avail). It happens to me all the time that a data structure that I ...


5

Open the file with OpenAppend not OpenWrite. Any Writes will then append to the file not overwrite.


5

HDF5 does not directly support complex numbers. Programs that do seem to be able to export complex numbers (like armadillo) to HDF5 will in reality split them into real and imaginary part and use their own non-standard convention for storing these. This means that while they can sometimes read back their own data, there is no compatibility between ...


3

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 support could not provide a more elegant solution so far. We use a trick here. In fact we don't have any options, but we need to add the option part to the ...


2

For simply saving numbers or lists to file, I personally prefer to use Put/>> and PutAppend/>>> to store data, and ReadList to retrieve it. For instance: (# >>> "file.dat") & /@ {1,2,3}; ReadList["file.dat"] (* {1,2,3} *) (# >>> "file.dat") & /@ {1,2,3,4,5}; ReadList["file.dat"] (* {1,2,3,1,2,3,4,5} *) You could ...


2

I would read the csv file as a stream. It's very quick. First, I use the following function to look for specific lines. ClearAll[readLine]; readLines[stream_, search_?StringQ] := With[{stro = FindList[stream, search]}, ImportString[StringJoin[Riffle[stro, "\n"]], "Table"] /; stro =!= {}] Then I open a stream: file = "data.csv"; str = ...


1

If you data is labelled "blah.xls" then your input should be Import["blah.xls"] Just make sure the data file is in the correct directory.


1

Leonid provided the following demo in chat: the basic idea is to use R's read.table header management before coming back to Mathematica. file = URLSave["http://samplecsvs.s3.amazonaws.com/TechCrunchcontinentalUSA.csv"]; Needs["RLink`"] InstallR[]; RSet["testfile", file]; REvaluate["testdata <- read.table(testfile, header=TRUE)"]


1

This method will work with the ragged data array provided. Example 1 data = Import["henris_data_s3.csv"]; vnames = Transpose[data[[{1, 2}]]]; vnames[[99]] {"L1_INJ", "GWIR"} Above is the 'name' of the 99th record. Table[vdata[vnames[[i]]] = DeleteCases[Drop[Map[ Quiet[Check[Part[#, i], Null]] &, data], 4], Null], {i, Length[vnames]}]; ...


1

Import["binary.txt"] in this case is equivalent to Import["binary.txt", "Text"] not to Import["binary.txt", "String"] Documentation states that Import["binary.txt"] "reads a text file, taking the character encoding to be "UTF8" by default." Whereas for format "String" documentation states that "imports a raw sequence of bytes and returns them as a ...


1

I think that the reason is that -- depending on the format -- Import does either use external programs, java libraries via JLink or the frontend for imports of most "nontrivial" formats. Only some -- mainly simple ascii or plain binary -- formats and of course mathematicas own syntax are directly "imported" with pure kernel functionality. As you correctly ...



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