Tag Info

Hot answers tagged

11

I worked on Interpreter. As far as the implentation is now, the DelimitedSequence parser does not support quoting, so what you want can't be done. We'll try to add it in a future version.


10

In this case it would be far more reliable to request the information from the source directly. You can find the source using your web browser's developer tool, in Google Chrome you find this information under "Network." It should look something like: Importing that data as JSON gives us a nested list of rules containing all the data: rawData = ...


7

Another solution would be to use SemanticImportString (new in 10). Borrowing some code from Mr.Wizard so that I can compare my solution to his: strings = ToString @ Row[RandomChoice /@ {{"-", ""}, {#}, {"e"}, {"-", ""}, Range@12}] & /@ RandomReal[{0, 10}, 15000]; Needs["GeneralUtilities`"] Internal`StringToDouble /@ strings // AccurateTiming ...


7

The best tool to work with the SEED format would be IRIS' own rdseed program. It might be possible to use Jrdseed with JLink and Mathematica, but I have not tried this. Typically SEED files are converted to other convenient formats for data processing, of which the SAC (Seismic Analysis Code) format is the most common one. Implementation: The following is ...


7

This is an ideal use case for SemanticImport, but unfortunately it has issues getting the commas right in version 10.0. Luckily, version 10.0.1 has already fixed this bug:


7

Steven, looking at the data you can see that you already have the latitude and longitude converted into de proper format under fields lng and lat. asamdataset[1] // Normal (*<|"Subregion" -> "57", "Reference" -> "2014-175", "Description" -> "GHANA:On 25 July, the 3,232 gross ton Kiribati-flagged product \ tanker MT HAI SOON 6 was boarded ...


6

Update Inspired by Andy Ross header = First @ iris; header = StringReplace[header,"."->""](Because Dot is protected in Mathematica) data = Rest @ iris; assign[name_, value_] := Evaluate[ToExpression[name]] = value; Thread[ assign[header, Transpose@data] ] ==================================================================== If you ...


6

Version 10 introduced Interpreter which would seem suited to this task: Interpreter[form] represents an interpreter object that can be applied to a string to try to interpret it as an object of the specified form. Interpreter["Number"]["1.23e-5"] 0.0000123 Unfortunately it seems that like many new-in-10 functions this is far from optimized. ...


3

First I saved the data in a file named "data.dat" as Text, then I imported your data, including the Delta data = Import[...] then the trick: data // ToExpression and here are the data {{1.171937359784618*10^6}, {Subscript[a, 1, 1] -> -39.07037581001687, Subscript[a, 1, 2] -> 32.83913739257574, Subscript[a, 1, 3] -> 47.04859760352587, ...


2

At this point I think it is probably best to import your data as a plain string and then extract your Rules using StringCases: text = Import["odd.dat", "Text"]; StringCases[text, x : Shortest["Subscript[" ~~ __ ~~ "] -> " ~~ NumberString] :> ToExpression[x]] {Subscript[a, 1, 1] -> -39.0704, Subscript[a, 1, 2] -> 32.8391, Subscript[a, 1, ...


2

Low-level file operators like Write won't work here because OutputStreams (such as you get with OpenWrite and OpenAppend) can't have their StreamPosition set before the end of the file. In general overwriting characters in an existing file isn't terribly trivial; you can use c-functions likefile_ptr = fopen(file, "rb+") to do this, but you're overwriting ...


2

Try constraining the execution time to something reasonable TimeConstrained[Import[filename, "Elements"], 1] this will abort the Import function after 1 second allowing you to skip the offending files. A list of non-offending files can be obtained with this: filelist = Select[FileNames["*.*"], (Length@TimeConstrained[Import[#, "Elements"], 1] > 0) ...


2

The best way to export your data and import it again is to use the WDX data format. Wolfram Language Documentation Center - WDX Data Format It allows for platform independent storing and exchange of information and data. Example Export["solve.wdx", Solve[7 Subscript[a, 1, 1] + 5 Subscript[a, 1, 2] == 17 && 2 Subscript[a, 1, 1] + 3 ...


2

You can read in the expression using Get: << "/yourpath/sample.txt"; c = Classify[%] or alternate forms: c = Classify[ << "/yourpath/sample.txt"] c = Classify[Get["/yourpath/sample.txt"]]


1

Yes, in order to create your list of images you can use the following piece of code: Join[ Thread@Rule[Import["~/Desktop/folder1/*.png"], "Day"], Thread@Rule[Import["~/Desktop/folder2/*.png"], "Night"] ] Of course you will need to change the file path and the properties (day/night) appropriately.


1

There doesn't be to be a way to Import the colours. The only available information are the following: {#, Import["~/test.col", #]} & /@ Import["~/test.col", "Elements"] Thus you indeed need to Import your Graph from the .col file and add the colours afterwards: g = Import@"~/test.col"; data = Import["~/test.col", "List"]; vclist = ToExpression ...


1

Use ToString Do[ Export[yourPathToFile<>ToString[i+20]<>".csv", yourData[[i]]] ,{i,0,22}



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