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

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 ...


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 ...


6

We can start by importing the file as an XMLObject: $url = "https://dl.dropboxusercontent.com/u/1012958/iTunes%20Library.xml"; $xml = Import[$url, {"XML", "XMLObject"}]; Short[$xml, 4] (* XMLObject[Document][ { XMLObject[Declaration][Version->1.0,Encoding->UTF-8] , XMLObject[Doctype][plist,Public->-//Apple Computer//DTD PLIST ...


6

Here's one way to resolve the CRLF problem. data = Import[fname, "Text"]; StringReplacePart[data, "\[Wolf]", StringPosition[data, "\n" ~~ DigitCharacter]]; StringReplace[%, "\n" -> ""]; StringReplace[%, "\[Wolf]" -> "\n"]; data2 = ImportString[%, "CSV"]; First, I import the file as a single text string. I notice in the file that all of the ...


6

I think that the existing comma-separated-values, fields, containing "new lines" are the offending elements in your file. If you do Length /@ Import["data.csv"] {64, 64, 64, 64, 64, 64, 1, 1, 25, 64, 64, 8, 1, 1, 1, 1, 1, 25, 7, 1, 1, 1, 1, 25, 1, 2, 2, 25, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, ...


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. ...


4

Paste is a command that, as a side-effect, inserts the contents of the clipboard into the current notebook selection. The return value is always Null, which means that Paste cannot be used for our purpose without some awkward notebook manipulation. There is an undocumented way to access the clipboard: ClipboardNotebook. NotebookGet[ClipboardNotebook[]] ...


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

You need to have sufficient precision in your input file to trigger an arbitrary precision representation automatically. In your example, you just need one more digit as, I believe, one digit past machine doesn't typically do it. ImportString[ "8.24574097909000040e+08,8.2457409790900004e+08", "CSV"] (* Out: {{8.2457409790900004*10^8, 8.24574*10^8}} *) ...


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"]]


2

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 ...


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, ...


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

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