Tag Info

Hot answers tagged

10

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


8

Using SemanticImport["testdata.csv"] I get on the exported data you provided which is the dataset you seek. But SemanticImport has been reported to have a few bugs, maybe that's why you can't get it to work. In the meantime, and in between time, you can use the much cleaner approach to obtain your dataset after using Import on your file: data = ...


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


3

I don't think SemanticImport has been designed to deal with multiple Excel sheets. I work around this problem using Import to get the number of sheets and their names, and to import them and ExportString to export them as "TSV" which, on its turn, can be imported by SemanticImportString. An intermediate conversion of DateObject/TimeObject to DateString is ...


3

For the first case, one way will be to read the entire file as a String and manipulate it e.g: txt = ReadList["dose.txt", String]; Then do something like: Flatten @ StringCases[txt, "Mean Dose [%]: " ~~ (x : NumberString) -> ToExpression @ x] {103.3} I guess you can turn it into a function: sValues[s_String] := Flatten @ StringCases[txt, s ~~ ...


3

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

Your file seems to be corrupt, there is one extra byte in the header section. Open in a binary clean text editor, search for "uK^2" and delete exactly one space following the 2. The file can then be read by this: (adapted from link in comment) f = OpenRead["test.fits", BinaryFormat -> True]; parsehead[hh_] := (metadat[#[[1]]] = #[[2]]; #) & ...


2

Assuming the XLS file is in this URL: url = "http://statlinks.oecdcode.org/982013061P1T001.XLS"; This gives you the list of sheets in the XLS file sheetslist = Import[url, {"XLS", "Sheets"}]; And you can Import the second sheet by Import[url, {"Sheets", sheetslist[[2]]}] Backtracking, now to get that URL... Get a list of links in the page: ...


2

Even though I don't see it in the documentation, you can use All when specifying what elements you want to import. So for an example Excel spreadsheet: We can import the 2nd and 5th elements from every row on the first sheet as such: Import["pathtoxlsx.xlsx", {"Data", 1, All, {2, 5}}] {{0.612328, 0.325049}, {0.909502, 0.206016}, {0.531286, ...


1

sheets = Import["sample.xlsx", "Sheets"] (*{"DataSet1", "DataSet2"}*) data = Import["sample.xlsx", "Data"] (*{{{"Country", "Value"}, {"AR", 10.}, {"BE", 20.}, {"SG", 30.}, {"TW", 40.}}, {{"City", "Value", "Color"}, {"Amsterdam", 10., "Blue"}, {"London", 20., "Red"}, {"Paris", 30., "Yellow"}}}*) Set[Evaluate[Symbol[#] & /@ sheets], data]; ...


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.



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