I have data such as,
{{[Part(33.0, 34.0), Part(33.0, 34.0), Part(31.0, 32.0), Part(30.0, 32.0), Part(29.0, 32.0), Part(28.0, 29.0), Part(28.0, 29.0)]}}
as text data.
I want to get number list of
{{33.0, 34.0},{33.0, 34.0}, {31.0, 32.0}, {30.0, 32.0}, {29.0, 32.0}, {28.0, 29.0},{28.0, 29.0}} then make it density plot or Histogram plot.
I tried to convert it as follows,
td0 = FileNames["myfolder/data.*txt"];td0data = Import[#, "Data"] & /@ td0;
(The out put is like
{{[Part(33.0, 34.0), Part(33.0, 34.0), Part(31.0, 32.0), Part(30.0, 32.0), Part(29.0, 32.0), Part(28.0, 29.0), Part(28.0, 29.0)]}}
)Hence, I did
ss = StringSplit[td0data[[1]], {", Part"}];sr = StringReplace[ss[[1]], {"(" -> "{", ")" -> "}"}];sdfirst = StringDrop[sr[[1]], 5];sdlast = StringDrop[sr[[-1]], -1];sj = StringJoin[sdfirst, sr[[2 ;; -2]], sdlast];sr = StringReplace[sj, "}" -> "},"];srd = StringDrop[sr, -1];
(Here the output was like
{33.0, 34.0},{33.0, 34.0}, {31.0, 32.0}, {30.0, 32.0}, {29.0, 32.0}, {28.0, 29.0},{28.0, 29.0}
))
So at last I wished I converted this String to Number, as
te = {ToExpression["srd"]};
The output was
{{33.0, 34.0},{33.0, 34.0}, {31.0, 32.0}, {30.0, 32.0}, {29.0, 32.0}, {28.0, 29.0},{28.0, 29.0}}
However, te was Null and I cannot even do ListPlot.I don't know why it doesn't work.
If I just input the line by copy and paste,
test= {{33.0, 34.0},{33.0, 34.0}, {31.0, 32.0}, {30.0, 32.0}, {29.0, 32.0}, {28.0, 29.0},{28.0, 29.0}};
I can write Histogram
Histogram3D[N[test], {{-100, 100, 1}, {-100, 100, 1}}, ChartElementFunction -> "GradientScaleCube"]
(Even here, I have a problem that I cannot set x, y plot range)
Although I can copy and paste by hand for a single file, it is hard to make many files by hand...
I have two questions:
- How to make "te" to number list?
- I want to make Histogram3D plot, but Could you tell me how to set the histogram plot range? Each histogram bar often become rectangle...