Hot answers tagged

10

I would like to link this W Community thread here where I asked for functionality like this in 2015 September, and explained why it's critical to have it. I can't link to individual posts but you can find it by searching the page for "StringToDouble". As Leonid mentioned, there is Internal`StringToDouble. This function is very fast, but it does not ...


5

Here's a solution using your example file. Import as RawJSON because this gives us much easier to manipulate associations. json = Import[ "https://raw.githubusercontent.com/d3/d3-plugins/master/graph/data/miserables.json", "RawJSON"] After inspecting the format manually, it's easy to extract vertices: vertices = json[["nodes", All, "name"]] Links ...


4

Import and ImportString handle the e number format okay. You might be able to Import directly from file, or use ImportString to process the data you've already read in: res = fromReadList ~StringRiffle~ "\n" ~ImportString~ "TSV" ~Cases~ {__,"Cake"|"Cookies",_};


4

Make some sample data consisting of numbers and spaces: samepleData = Module[{seed = ToString@Table[RandomInteger[{0, 10000}], 50]}, StringReplace[seed, {"{" -> " ", "}" -> " ", "," -> RandomChoice[{" ", " ", " "}]}]] (* 7476 8829 1505 3337 7282 7244 ...


3

You have problem because your variable a is already a graphics object. This works for me: file = Export["fig.pdf", Plot[Sin[x], {x, 0, 2 π}]] g = First[Import[file]] Graphics[{g[[1]], Inset[x^2 + y^2 == 1, {200, 200}]}]


2

Import takes all sheets, which nests the data. First@ takes the first sheet formatting the data you need for the subsequent expressions. test = First@Import["Velocidade Angular.xls"]; time = test[[All, 1]]; x = test[[All, 2]]; f = Interpolation[Transpose[{time, x}], InterpolationOrder -> 3]; Show[ ListPlot[test[[All, 1 ;; 2]], PlotStyle -> Red], ...


2

Number counting approach Since your file contains (with rare exceptions) only 3 numbers on each line and the data has dimensions {400,4001,2}, it is possible to calculate how many lines you should read in order to obtain the first 40 sets out of 400. At first, some checks: data = << "EigF-V1_1.0-V2_0.000.txt"; Dimensions[data] {400, 4001, 2} ...


2

Here is an example of using FFmpeg to convert a video to images and import them into Mathematica. I'm using the jfkrice.avi video as an example. This will convert the video to a list of images ffmpeg -i jfkrice.avi -r 10 -f image2 jfkrice/%05d.png the number 10 means 10 images per second. Then we can use Mathematica to import them imgls = Import /@ ...


2

SemanticImport will handle it. Specify the column types explicitly. Example with one column: SemanticImportString[ "-5.07248931892817e-05+2.50260543778902e-18i -5.0723848172051e-05+2.870855441657444e-17i", {"ComplexNumber"} ] This returns a Dataset which you can convert to a list using Normal. Update: I can import your file without problems in ...


1

Szabolcs Horvát has a great bit of code that makes bring in tabular data via copy and paste super easy: Pasting tabular data from the web http://szhorvat.net/pelican/pasting-tabular-data-from-the-web.html


1

The problem here stems from the filenames being in alphabetical order. If you separate the numbers from the ".txt" suffix with StringSplit, you can use ToExpression to get Mathematica to treat them as numbers and put them in numerical order. Then use Ordering to put the original list of filenames in the same order as the list of numbers. filelist = {"1.dat"...



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