Hot answers tagged

16

Your code is recalculating Mean[Hrank] and StandardDeviation[Hrank] with each comparison, making it extremely slow. Store them separately, and the calculation becomes much faster. I simulated an Hrank vector using: Hrank = RandomInteger[{0, 1000}, 200000]; And then did: mean = Mean[Hrank]; stddev = StandardDeviation[Hrank]; HighRank = Cases[Hrank, ...


5

updated based on comment feedback One more approach, using LibraryLink. Create a C file called strto.cpp as follows: #include <cstdlib> #include "WolframLibrary.h" EXTERN_C DLLEXPORT int wolfram_strtol(WolframLibraryData libData, mint Argc, MArgument *Args, MArgument Res) { char *string; mint base; mint result; string = ...


4

You can read the binary data in the NumericArray (or PackedArray) using deserialization from the WXF format. To do this, simply add a header on the fly in front of the binary data. WXF Format Description Example: (* Create Binary File *) data1 = N@Table[Sin[x], {x, 0, 1000 Pi, Pi/1000}]; data2 = N@Table[(Sin[x] + 0.25 Sin[11 x]), {x, 0, 1000 Pi, Pi/1000}];...


4

HTML >> Import Elements So you can use "FullData" in place of "Data": ImportString["<table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td> </td> <td>Smith</td> <td>50</td> </...


3

The implementation of $ScriptInputString in wolframscript is buggy. I have found that providing !cat to an import function (ReadString, Import, ...) is a more stable way of reading from stdin. When using wolframscript, this approach only works in cases where $ScriptImportString doesn't, presumably because the stream is already consumed otherwise. A ...


2

Try mydata2 = Import["gstar.xlsx", {"Data", 1, All, ;; 2}]; Interpolation[mydata2] {"Data", sheetlist, rowlist, columnlist} specification extracts data from sheets in sheetlist the rows in rowlist and columns in columnlist. So {"Data", 1, All, ;; 2} says "get the array of data in columns 1 and 2 form all rows of sheet 1". See XLSX >> Import ...


2

Well, to summarize my comments: {DateObject@StringReplace[#1,x:DigitCharacter..~~"."~~y:DigitCharacter..~~"."~~z:DigitCharacter..~~" "~~rest__:>z<>"/"<>y<>"/"<>x<>" "<>rest],#2}&@@@#&/@ (Import[#,"Table","FieldSeparators"->";"][[2;;,{-2,-1}]]&/@allfiles) So, if you know that you need only last two ...


1

I just found an answer to my own question. I'm not sure it's a good answer since it would open a new browser. I would prefer to do it headlessly. session = StartWebSession[]; myLink = "https://ui.adsabs.harvard.edu/abs/arXiv:1609.05206/references"; WebExecute[session, "OpenPage" -> myLink]; Pause[3]; (*pause for 3 seconds to let JavaScript run*) ...


1

Use the second argument of Import to specify the format explicitly, e.g., Import["proton"<>"Dauau1525-401.data", "Table"]


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