Tag Info

New answers tagged

2

Easy fix: Export the result in the form ExpressionML Here is the code. N[ Sum[2/10^((n*(Floor[9/n] + 1) - 9)4), {n, 1, Floor[Sqrt[ 9]]}] + Sum[ 2/(10^((n(Floor[9/n] + 1) - 9)4) (10^(n*4) - 1)), {n, 1, Floor[Sqrt[ 9]]}] + Sum[2/(10^((o^2 - o - 9)* 4)*(10^(o*4) - 1)), {o, Floor[Sqrt[9]] + 1, 10}], ((10 + 1)^2 - 9)* 4] // ...


2

Being able to use this provides us with a way to produce quite secure CDFs designed for FreePlayer. Maybe it is a problem with encoding somewhere or with overloaded definitions of Get. Nevermind, as pointed out by Rolf Mertig if one uses OpenRead with DefineInputStreamMethod to convert a binary file to a stream, everything seems to work. Steps: ...


1

Corrected with 2012rcampion's feedback data = Import["test.txt"] (*"(-0.000421863,1.58589e-09)(-4.04766e-05,2.67116e-07)(-8.4396e-06,-1.\ 54976e-07) (-0.000421863,1.58589e-09)(-4.04766e-05,2.67116e-07)(-8.4396e-06,-1.\ 54976e-07)"*) data = ToExpression[ StringSplit[ StringReplace[data, {","->"+I*","(" -> "", "e" ...


6

Update: Successfully debugged!! I don't know why I do this ... This is a bug in Mathematica's MAT v4 reader that can easily be fixed on the user-side. First, let's try to do the import, which will trigger loading the .mat-importer functionality. Now let's look at the following function System`Convert`MATDump`myImportMAT4: Notice the Switch listing ...


2

The underscore _ as a pattern matching mechanism is reserved for mathematica. Therefore, either use something like dataM = ReadList[strm, Table[Record, {12}], NullRecords -> True, RecordSeparators -> {",", "\n"}]; output = Table[Flatten[{ToExpression[Drop[dataM[[i]], -1]], Last[dataM[[i]]]}], {i,1,Length[dataM]}]; or remove the underscore in your ...


2

No. Not Natively. gephiexports = {"CSV", "GDF", "GEXF", "GraphML", "Pajek", "XLS","PDF", "SVG"}; Intersection[gephiexports, $ExportFormats] (* {"CSV", "GraphML", "Pajek","PDF", "SVG", "XLS"} *) GEXF is an XML based format so you may be able to crib a parser in Mathematica if you really want to. Update Gephi's website is somewhat contradictory on ...


0

If you're using URLSaveAsynchronous then you're automatically downloading in parallel and don't need to mess around with Parallel and other explicitly parallel constructs. I wrote a bit of code to handle scraping images from the web some time ago. First we get our list of URLs: urls = "http://www.explainxkcd.com" <> # & /@ StringCases[ ...


2

I can reproduce this problem on OS X with Mathematica 10.0.2, but with XLS and XLSX files only. Thus it's different from this bug which existed in version 10.0.0 and affected all files, and was fixed later. I believe that this is a bug and you should report this to Wolfram Support so it can be fixed. Mathematica.SE is not a website run by Wolfram ...


1

You might fix the garbage you are getting with ToExpression: ratevector = Import[file, "CSV"][[1]] // ToExpression I'd consider that a bit of a hack and prefer to understand why you are getting strings in the first place though. edit I think I figured out whats going on -- It seems if your file contains tabs, ie. ...


0

In your last input the import is ok and the length is 1 because you have list of depth 2 To get what you want try this: testimport = Import["~/ratevectorfilename_.csv", "CSV"][[1]]


1

Take a look at how the data is imported first. Using the data provided in the question. testing = Import["sample.tsv"] (*{{"time distance"}, {"1 25"}, {"2 43"}, {"3 43"}, {"4 \ 54"}, {"5 65"}, {"6 67 "}, {"7 68"}, {"8 23"}, {"9 \ 99"}, {"10 35"}}*) You can see that the data is imported as a single text per record. Importing ...


8

As mentioned in the comments and the documentation, importing from Excel files allows for multiple sheets. Thus, a single-sheet file will have what you refer to as an "extra" pair of curly braces. To eliminate this behavior, use: Import["<file.xlsx>",{"Data",1}] The above command will import just the first datasheet.


10

CSV: Import["file.csv"] imports a CSV file, returning an array. whereas XLSX: Import["file.xlsx"] imports all sheets of an XLSX file, returning the result as a list of arrays. If the file contains a single sheet, you can eliminate the extra curly braces using the second argument of Import as in @bobthechemist's answer, or simply using Part: ...


0

You can use low level file operations : stream = OpenRead["pathtoyourfile"]; Find[stream, "StartOfData"]; mydata = ReadList[stream, Number, RecordLists -> True] Close[stream]; returns {{0.000333324, 39.2921, -1.90214, 1.1479*10^-41, 49.9689}, {0.00533333, 39.3179, -1.46083, 12.7188, 50.0075}, {0.0103333, 39.3443, -1.05422, 12.6666, 50.0139}, ...


1

If you get irritated with Import, you can use streams: fs = OpenRead["/path/to/data.txt"]; Find[fs, "StartOfData"] data = {}; ln = Read[fs, Table[Number, {5}]]; While[Length[ln] == 5, AppendTo[data, ln]; ln = Read[fs, Table[Number, {5}]]; ] Close[fs]; AppendTo gets slow at very large arrays, but {less than 1 million, 5} shouldn't have a problem.


0

ImportString[StringTake[#, { StringPosition[ # , "Data starts here:"][[1, -1]] + 2, StringPosition[ # , "more junk"][[1, 1]] - 2 }], "Table"] &@ Import["test.dat", "Text"] alternately ( note here I've put the delimiting string lines in the list form they end up in when ...


1

Try something like: imageFileNameList = {"1.jpg", "2.jpg"}; imageList = (Import[#]&) /@ imageFileNameList In the format you used, the Import function was expecting a string and found a list. Be sure to include the path to the files as well.


2

No "real" answer, but a deeper analysis into the behavior you experienced: file = "original.m"; fileEnc = "enc.m"; (* alphabet for password: [0-9a-zA-Z] *) alphabet=Sort[CharacterRange @@@ {{"a", "z"}, {"A", "Z"}, {"0", "9"}}//Flatten, ToCharacterCode@#1 < ToCharacterCode@#2&]; (* checking and recording success of decryption together ...



Top 50 recent answers are included