how to read such kind of list?

Mathematica

    Next

  • 1. current directory
    Hi, I would like to know how to get a path of an *.m file as a procedure inside the same *.m file. With best regards, gregor
  • 2. Complex number after NIntegrate
    Hi all! I need to do the following. I am using mathematica to take a multi-dimensional(8-mentional) integral with NIntegrate and MonteCarlo method. But there is one problem I couldn't solve. Mathematica gives complex number after NIntegrate. Integrand is a some kind of exponential function with sums of logarithms in exponent. So, what i do wrong and may be i have to change some options of NIntegrate? thanx
  • 3. Vector algebra
    Hi, I'm trying to factorise this vectorial expression x.a+x.b to give x.(a+b) using mathematica. I expected the "collect or factor" command to work but it doesn't.Could you please suggest a possible way of carrying out this factorisation. many thanks
  • 4. Finding k-clique
    I would like to get the number of k-cliques in a Graph and a Function that returns all k-Cliques. Combinatorica provides only MaximumClique[g], which returns only the largest Clique in a Graph. Does anybody have an idea how to solve this problem in mathematica? I found a method in Java: Finding k-cliques using Backtracking with cutoffs pruning. Is ist possible to translate a Java Code to Mathematica?

how to read such kind of list?

Postby 863 » Wed, 23 Jul 2008 17:04:02 GMT

Hi, I'm having troubles with read in such kind of list:(between the
lines)
_____________________________________________________________________________
The stat results of Quantum Dots of file : D:\ProGram\qd 2.1.2\1.TXT

totally 110 QDs were segmented

  QD number per cm^2: 4.36659e+010 per cm^2
         mean height: 5.292516 nm
       mean diameter: 28.801531 nm
       mean distance: 33.309811 nm
       area coverage: 0.291367
      volume density: 0.545079 nm^3 per nm^2
    mean orientation: 1.271796 degree with x-axis
mean MajorAxisLength: 28.372259 nm
mean MinorAxisLength: 20.458377 nm

Diameter	Height	Area	MajorAxisLength	MinorAxisLength	Orientation
CentroidX	CentroidY	Volume	Distance
30.654263	5.682305	738.025950	31.117139	23.106343	-1.622242	15.319892
215.548346	1593.049175	48.741649
26.082407	5.763518	534.300037	25.935928	20.248467	-27.230550	10.990649
349.057494	1109.325936	30.633786
16.992852	2.057310	226.789224	15.903377	11.404470	-80.582608	5.929246
419.606587	104.229902	32.471795
33.184213	5.232010	864.874160	33.258266	23.873106	2.544861	33.037368
170.140864	1416.598341	40.478731
34.698269	6.372842	945.595748	35.071694	25.066265	0.415529	35.679808
386.624306	1878.842938	27.901502
32.287176	6.186880	818.747538	31.862749	23.366885	-8.171290	36.054502
67.137732	1757.760754	51.324165
____________________________________________________________________________________

 I have dozens of such kind of lists and actually what i'm interested
is the data not these letters.However i can't figure out by
Read["**.txt",Number,RecordList->True]
How to sovle this problem?
I really appreciate your help.Thanks!


Re: how to read such kind of list?

Postby Thomas Dowling » Wed, 23 Jul 2008 19:39:05 GMT

ello,

Although there are probably better ways, I would use Import rather than
ReadList


Something like the following ...

list = Import["/Users/..../test.txt", "Table"]


Out[45] = {{"The", "stat", "results", "of", "Quantum", "Dots", "of",
"file",
":", "D:\\ProGram\\qd", "2.1.2\\1.TXT"}, {}, {"totally", 110, "QDs",
"were", "segmented"}, {}, {"QD", "number", "per", "cm^2:",
4.36659*10^10, "per", "cm^2"}, {"mean", "height:", 5.29252,
"nm"}, {"mean", "diameter:", 28.8015, "nm"}, {"mean", "distance:",
33.3098, "nm"}, {"area", "coverage:", 0.291367}, {"volume",
"density:", 0.545079, "nm^3", "per", "nm^2"}, {"mean",
"orientation:", 1.2718, "degree", "with", "x-axis"}, {"mean",
"MajorAxisLength:", 28.3723, "nm"}, {"mean", "MinorAxisLength:",
20.4584, "nm"}, {}, {"Diameter", "Height", "Area",
"MajorAxisLength", "MinorAxisLength", "Orientation", "CentroidX",
"CentroidY", "Volume", "Distance"}, {30.6543, 5.68231, 738.026,
31.1171, 23.1063, -1.62224, 15.3199, 215.548, 1593.05,
48.7416}, {26.0824, 5.76352, 534.3, 25.9359, 20.2485, -27.2306,
10.9906, 349.057, 1109.33, 30.6338}, {16.9929, 2.05731, 226.789,
15.9034, 11.4045, -80.5826, 5.92925, 419.607, 104.23,
32.4718}, {33.1842, 5.23201, 864.874, 33.2583, 23.8731, 2.54486,
33.0374, 170.141, 1416.6, 40.4787}, {34.6983, 6.37284, 945.596,
35.0717, 25.0663, 0.415529, 35.6798, 386.624, 1878.84,
27.9015}, {32.2872, 6.18688, 818.748, 31.8627, 23.3669, -8.17129,
36.0545, 67.1377, 1757.76, 51.3242}}


I can then manipulate the above list. For example,

list[[-7 ;; -1]]

Grid[%]

Or, if I just want data (no headings)

Grid@list[[-6 ;; -1]]

I use Mathematica 6.

Tom Dowling


On Tue, Jul 22, 2008 at 8:58 AM, 863 < XXXX@XXXXX.COM > wrote:


Re: how to read such kind of list?

Postby 863 » Thu, 24 Jul 2008 19:23:33 GMT

Hi, Tom,
I  tried: ReadList["**.txt",Word] and "Partition" to get sublists.
Obviously, yours is the best way.
Pity there is no such command "Grid" in V.5.0 I use, but i can figure
it out
thanks for your help


On 7=D4=C222=C8=D5, =CF=C2=CE=E76=CA=B139=B7=D6, "Thomas Dowling" <thomasgd=




Re: how to read such kind of list?

Postby David Bailey » Tue, 05 Aug 2008 16:23:39 GMT


I would tackle this by reading in the data as a list of strings:

ReadList[file,String]

The first few items of the resultant list could be handled individually 
to extract the numerical values - say by using a string pattern to 
extract just the number and the using ToExpression to convert the string 
to a number.

You could then use Drop to strip off the front of the list and leave 
only the array of numbers (I am assuming that the lines do not alternate 
in length as they appear to do, but that they are uniform lines of data.

This data could be converted thus:

Map[ImportString[#,"List"]&,remaininglist]

David Bailey
 http://www.**--****.com/ 



Return to Mathematica

 

Who is online

Users browsing this forum: No registered users and 33 guest