Tag Info

17

This is not currently supported by the built-in functions, but there is a function called SVGImport in the function repository that can do this: https://resources.wolframcloud.com/FunctionRepository/resources/SVGImport

11

After some mental hemming and hawing, I decided it'd be good to have a proper answer about importing HTML tables using something other than the often buggy "Data" field. So here's what I got. First something to pull all the "table" fields: getHTMLTables[url_String?(StringStartsQ[URLParse[#]["Scheme"], "http"] &)] := getHTMLTables[Import[url, {"...

9

One needs to be careful and construct the HTTPResponse properly before we ask GenerateHTTPRespone to produce the final thing so that it can be consumed by any HTTP client outside of WL world. The following explicit MIME specification will solve the above problem. res = HTTPResponse[ ExportString[Plot[x, {x, 0, 1}], "PNG"], <|"ContentType" -> "...

8

Here's a version of the script that works: #!/usr/bin/env wolframscript -print All -run \'Needs[\"ComputerArithmetic\"]\' Ulp[1000.] This is a limitation of -print All that we probably should either document or find a fix for, though the latter is rather challenging. When executing a script normally or using -print, wolframscript can essentially tell ...

8

You just got to remove the initial data:image/jpeg;base64,, everything after that is base64 encoded pixel data. data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"]; data = StringReplace[data, "data:image/jpeg;base64," -> ""]; ImportString[data, "Base64"]

6

With the ability to connect to Python I found this snippet of code helpful. It imports a STATA .dta file using pandas and then outputs it as a Wolfram Dataset. importDTAMP[fileName_] := Module[{}, python37 = StartExternalSession[<|"System" -> "Python", "Version" -> "3.7.3"|>]; ...

6

Alternative answer: Use the SVG importer from my Prototypes paclet: https://github.com/arnoudbuzing/prototypes/releases/tag/0.5.6 To install the paclet, run this command: PacletInstall["https://github.com/arnoudbuzing/prototypes/releases/download/v0.5.6/Prototypes-0.5.6.paclet"] Note that this paclet has many many functions, but you may be able to ...

6

Assuming that I understood your right... making my toy-data and the filenames data = Table[RandomInteger[200, 20], {60}]; files = StringJoin["data", #, ".csv"] & /@ (ToString /@ Range[60]) export... Export[#[[1]], #[[2]]] & /@ ({files, data}\[Transpose]); Get the data in, similar like you did: inFiles = FileNames["*.csv", NotebookDirectory[]]; ...

6

Assuming I understand your data structure correctly, you could do something based on the following: SplitBy[Import["file.txt", "List"], StringMatchQ["New entry."]][[2 ;; ;; 2]] This imports the file as a list of strings, and then splits the list into sublists everytime an element is "New Entry.". You can then take ...

5

You should always specify the format in Import. "Data" is not the format. It is the input element. Add the format to the command. If you don't, the system will guess the format based on the file contents and the file name. I don't think it's a good idea to rely on guesses when any level of reliability is expected. XLSX files are in fact ZIP files, so ...

5

If your only goal is to get a Dataset, then just use cv19DeathsCSV = Import[ "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv", "Dataset", "HeaderLines" -> 1 ] I can't tell you why SemanticImport is doing what it does, other than it uses heuristics ...

5

You can work like this: import the data, ending the Import expression with a semicolon so to not display the entire table. rbraw = Import["https://raw.githubusercontent.com/benhowe75/rubidium_hyperfine_414/\master/simple.csv", "Dataset", HeaderLines -> 1]; Then you can use the name of the dataset and specify the elements you want to display with ...

4

You could try using ReadList instead. For example: ReadList[ StringToStream @ "{a,a+b+b+c,d}", Hold[Expression] ] {Hold[{a, a + b + b + c, d}]}

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

Change the URL to request the data in CSV format from Google Sheets (instead of HTML, which is perhaps not the best format for structured tabular data): Import["https://docs.google.com/spreadsheets/d/1F3uGfNJH-hch3NfnvZvqzg8vqmMLUkMF2dgAsHPP66s/gviz/tq?tqx=out:csv&tq&gid=0", "CSV"]

4

a = Import["modeshapes_evolution.txt", "Lines"]; b = StringSplit[a, ","]; c = StringReplace[#, "E - " -> "*10^-"] & /@ b; data = ToExpression[c] The above works on a text file with lines that contain your sample data. Better method: To use MMA's built-in data format conversion, as suggested by @Roman, you could simply remove the spaces and read ...

4

<< is meant to be used only with a simple name on the right, and it will interpret this name as a string. << name means Get["name"] and not Get[name]. << f[] means Get["f[]"] and not Get[f[]]. There are also issues with precedence. << x <> y means StringJoin[ Get["x"], y ]. Try this: Hold[<< x <> y] // FullForm (...

4

{dxf, edges, vd} = Import["(...path...)/input.dxf", #] & /@ {"Graphics3D", "LineData", "VertexData"}; edges = UndirectedEdge @@@ edges; gives dxf = Graphics3D[{{EdgeForm[], {RGBColor[0., 0., 0.], {Text[StyleForm["1", FontColor -> RGBColor[1., 0., 0.]], {75., 25., 0.}, {0, 0}], Text[StyleForm["2", FontColor -> RGBColor[1., 0., 0.]], {115....

4

Nice spectrum. rbraw = Import["https://raw.githubusercontent.com/benhowe75/rubidium_hyperfine_414/master/simple.csv", "Dataset", HeaderLines -> 1]; rbraw[Map[Reverse]][ListPlot[#, PlotRange -> All, ImageSize -> 500] &]

4

In chrome, after you run the ngram query, you can go to the "Developer tools", find the source file starting with graph?content=", search for the string var data (search is under the triple dots on the upper right corner), and find the time series var data = ...

4

Import[myfile.ndjson,"JSON"] doesn't work because the file as a whole is not valid JSON. But each line is valid JSON and so we can treat the file as a stream and read it one line at a time. The simplest way to do this would be stream = OpenRead@"~/test.ndjson"; ClearAll[line]; result = {}; While[line =!= EndOfFile, line = ReadLine[...

3

You can use the following operator: op = ToExpression@*StringReplace[{"e+" -> "*^", "e-" -> "*^-", "i" -> "I"}] which can then be applied to strings of numbers: op["0.677 + 9.121e-12i"] op["1.247e-12 + 0.182i"]

3

Also possible are Import["test.m",{"Package","HeldExpressions"}] returning {HoldComplete[{a, a + b + b + c, d}]} and Import["test.m",{"Package","InactivatedExpressions"}] giving {{a, Inactive[Plus][a, b, b, c], d}}

3

@halirutan you can now register the format extension using this function from Wolfram Function Repository: https://resources.wolframcloud.com/FunctionRepository/resources/RegisterFormat

3

In version 10.1 it appears "FullData" will do this, but it also produces some extra fluff that will need to be trimmed. dat = Import[ "https://docs.google.com/spreadsheets/d/1F3uGfNJH-\ hch3NfnvZvqzg8vqmMLUkMF2dgAsHPP66s/gviz/tq?tqx=out:html&tq&gid=0", "FullData"]; dat[[2, 2 ;;, ;; 7]] // Grid // TeXForm $\begin{array}{ccccccc} 341367901 & ... 3 m = Import["bessel.xlsx"] // Transpose // Flatten[#, 1] & // Delete[#, 1] & This imports, the file, flattens it to a matrix and deletes the header row. You may need the complete path name if the data is not in the current directory. Then Table[BesselJ[m[[i, 2]], m[[i, 1]] m[[i, 3]]], {i, Length[m]}] {0.0349786, 0.0217276, 0.0136127, 0.0676302, ... 3 As I attempted to explain to you in the comments, the issue is due to your method of changing the .xlsx extension to .xls by renaming it through your file browser (i.e., Finder or Windows Explorer) instead of resaving it using the software within which the original .xlsx file was created. Your questions in an attempt to solve this, while well-thought-out, ... 3 I'm new and this is my 1st answer. Try the following: Button["Import", file = SystemDialogInput["FileOpen"]; If[ Not@TrueQ[file ==$Canceled], data = Import[file]], Method -> "Queued"]

3

I do not know the internals of Mathematica but I noticed that ToString removes digits after a second group of zeroes. Try this code. inp = {0.00008200000000000003, 0.333333333333333312, 0.2333999999999999976}; ToExpression[RowBox[{ToString[#]}]] & /@ inp // FullForm Previous answer The function N@Rationalize[#, 10^(-\$MachinePrecision + ...

3

Update Plot data for several regions provinces = {"lombardia", "sicilia"}; dataByProvince = covid19Italy /@ provinces; dataByProvince // Map[(KeyTake[#, {"date", "total infected"}] &), #, {2}] & // Values // Flatten[#, 1] & // DateListPlot[#, ScalingFunctions -> "Log", PlotLegends -> Capitalize@provinces, PlotMarkers -&...

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