Tag Info

Hot answers tagged

6

You can store the data using tagging like so: XMLData = Import["Z:/XXX/XXX/XXX.mw", "XML"]; SetOptions[EvaluationNotebook[], TaggingRules -> {"xmlData" -> XMLData}] Then in future it can be recalled in the same notebook using the following line. (The tagged data can be recalled even if the code above is deleted.) XMLData = ...


5

You are right - those formats are for statistical software packages. I've noticed in Big Data discussions that Mathematica does not want to extend the range of acceptable data formats leaving the job to third-party software. I would recommend to use software like 'Stat/Transfer', which is a usual practice for such tasks. If you take data from WVS, say ...


4

This should do the trick - disclaimer the file is 1.4Gb so everything takes a veerryyy long time on my MacBook air, and you will need an active internet connection for InstallR to work. Note you have to escape \ internal R file paths and anything else that uses a double quote. Firstly download the rdata version of the file from the link given. ...


4

Import the data and chose the columns that contain relevant information: In: data = Import["file.csv"]〚All, {1, 3, 7}〛 Out: {{"Female", "A", 1}, {"x", "A", 2}, {"Male", "A", 3}, {"y", "B", 4}, {"Female", "B", 5}, {"Male", "B", 6}, {"Female","C",7}, {"Male", "C", Null}} Select those entries that start with "Female" or "Male" and wich also have a ...


3

I used the answer above to create a small function to grab a bit of sound using the default microphone on my computer. Clear[recordTime]; recordTime[t_: 1] := Module[{device = FrontEndExecute[FrontEnd`RecordSound[5]]}, FrontEndExecute[FrontEnd`RecordSound[1, Keys[First[device]], 1]]; Pause[t]; FrontEndExecute[FrontEnd`RecordSound[2]]; ...


3

Have a look at the documentation for CSV. The first issue you have is that your file extension is .txt so Mma imports it as text file instead of a CSV file. Your second issue is that "Table" is not a supported element for either CSV or TXT so I think it is just being ignored. Even though your file does not have the .csv file type you can still tell Mma ...


3

imp = Import["file.csv"] (* fake data *) scores = imp[[Join @@ Range[{5, 6}, Length@imp, 12], {3, 7}]]; MFscores = GatherBy[scores, First] {{{"Cayuga ISD", 494}, {"Cayuga ISD", 489}}, {{"Elkhart ISD", 513}, {"Elkhart ISD", 455}}, {{"Westwood ISD", 519}, {"Westwood ISD", 451}}, {{"LaPoynor ISD", ""}, {"LaPoynor ISD", 451}}} You ...


2

With a sheet containing Group Distric DistName Cityname regname region Math Critrd All Students 1. s w g 1. 451. x female 5 n t e 7 12. x male 2. r y k 4. 5. x All Students 7. g m m 9. 456. x and the spreadsheet file named Book.xlsx and in a place where Mathematica can find it then this data = First[Import["Book.xlsx"]]; Cases[data, ...


2

It seems that in version 10 of Mathematica (see Documentation Center), the importation of compound .h5 data is now supported, e.g. : Import["ExampleData/image.h5", {"Datasets", "/image24bitpixel"}]


2

If your data is or can be coerced into a rectangular array of machine Integer, Real, or Complex numbers (all the same type), then you can use ToPackedArray to reduce the amount of memory required, as well as make operations on the data faster. One might have hoped that Import would do this automatically, but it doesn't. You can use ByteCount to see how ...


2

You could import each frame of your movie as a separate image, then use ListAnimate on this list to generate an animation on which you would then have full control. I am going to generate a static image and a test movie to play with: staticimage = Rasterize@Plot[Sin[x], {x, -Pi, Pi}, AspectRatio -> 1, ImageSize -> Medium]; Table[Rasterize@Plot[Sin[i ...


2

You have trailing commas on each line that are imported as empty strings. imported = Import["csv.txt", "CSV", HeaderLines -> 2] {{700.0443115, 0.08416349441, ""}, {699.0369263, 0.08557280153, ""}, {698.0291138, 0.08568932861, ""}, {697.0210571, 0.08601997793, ""}, {696.0126343, 0.08787558973, ""}, {695.0039063, 0.08656696975, ""}, {693.994812, ...


2

Played around a bit and got to a point where I think I can let you finish it off (and make it more "automatic" and syntactically pleasing). file = "/path/to/file/JCO1DADAP_0000" For an unformatted Fortran 77 file I usually start by opening the stream an looking at the first "Integer32". This will determine how many bytes the record uses. str = ...


2

OP's stuff: html = "<div style=\"text-align: center;\"> This is <span style=\"font-size: 21px;\"> <i>an example</i></span> of a <u> <font face=\"Georgia\" style=\"font-size: 19px;\">text \ cell</font></u> with <font color=\"#c14dff\" style=\"\">complex styles</font> \ ...


2

There is a stray quote on the second line, in YNL039W|B"|TFC5|TFC7|TFIIIB90 the effect of which can be seen here (test.txt is your input) In[1]:= test=Import["~/Desktop/test.txt","TSV","Numeric"->False]; In[2]:= Length/@test Out[2]= {17,7} In[3]:= test//Last//TableForm Out[3]//TableForm= SGD S000004984 BDP1 GO:0000126 ...


1

I think you may just have your record separators set incorrectly. Note also that, if those lines are representative of the whole file, then your values are space-separated, rather than comma-separated as you seemed to suggest in your original post. I copied those lines straight into a text file, then used ReadList to read them back in. I set the ...


1

Code outline: ClearAll[XMLNote]; (*modified, only act on target tags*) XMLNote[ XMLElement[tag : "section" | "TextHeading", attributes_, data_], m_Integer ] := ... (*new, for other tags pass down XML elements*) XMLNote[XMLElement[_, attributes_, data : {__XMLElement}], m_Integer] := Sequence @@ (XMLNote[#1, m + 30] &) /@ data; ...


1

You need to flatten the list and convert elements to numeric values: prob = Import["/home/Desktop/test1.txt", "Table"]// ToExpression// Flatten; Then you can find the Shannon Entropy (without a do loop and initialization): alpha = 1.1; t = Length[prob]; shannon = Sum[-prob[[i]]*Log[prob[[i]]], {i, 1, t}]; Print[{alpha, shannon}] (* ...


1

I would do this line by line, using the ability of ReadList to read a single record via its third argument. You can then check whether you want to keep that record, and Sow it if you do. Thus, I would use something like this: importFunction[path_, columns_, maxRows_:∞] := Block[ {inputstream, record, i = 1}, inputstream = OpenRead[path]; Reap[ ...


1

If you look at the InputForm of the List you get from Import, you will notice that all those "empty" entries are actually an empty string, i.e. "". You can then replace the string with an empty Sequence[], and the empty sequence will automatically be flattened out of the list. I generated a .CSV file with your pattern of pairs of columns of different ...



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