Plotting on .csv file is not displaying

I am trying to plot from a csv file that looks like:

|1980-01-01;01:00;297.19;89.76;1006.71;2.59;181.01;0.012526;0.000000;0.000000;0.0000|
|1980-01-01;02:00;296.99;90.49;1006.07;2.44;183.91;0.018802;0.000000;0.000000;0.0000|
|1980-01-01;03:00;296.87;90.70;1005.71;2.26;184.39;0.012541;0.000000;0.000000;0.0000|
|1980-01-01;04:00;296.93;89.75;1005.74;1.89;182.67;0.013850;0.000000;0.000000;0.0000|
|1980-01-01;05:00;297.20;87.42;1006.10;1.24;177.67;0.009788;0.000000;0.000000;0.0000|
|1980-01-01;06:00;297.32;85.38;1006.58;0.66;160.16;0.011803;0.000000;0.000000;0.0157|
|1980-01-01;07:00;297.49;85.48;1007.18;0.56;95.13;0.014820;0.000000;0.000000;53.6664|
|1980-01-01;08:00;298.48;81.85;1007.98;0.96;70.82;0.014547;0.000000;0.000000;223.6198|
|1980-01-01;09:00;299.62;76.24;1008.41;1.26;56.43;0.008319;0.000000;0.000000;435.0896|
|1980-01-01;10:00;300.63;71.33;1008.36;1.42;42.39;0.004263;0.000000;0.000000;617.4373|
|1980-01-01;11:00;301.56;66.64;1007.95;1.30;32.10;0.001461;0.000000;0.000000;754.2593|
|1980-01-01;12:00;302.31;62.55;1007.31;1.17;28.02;0.000682;0.000000;0.000000;813.8093|
|1980-01-01;13:00;302.82;59.48;1006.42;1.03;33.30;0.000911;0.000000;0.000000;797.8347|
|1980-01-01;14:00;303.05;57.66;1005.44;0.94;44.49;0.000192;0.000000;0.000000;707.8373|
|1980-01-01;15:00;302.97;57.47;1004.72;0.97;66.73;0.000126;0.000000;0.000000;552.5787|
|1980-01-01;16:00;302.75;58.72;1004.36;1.05;93.58;0.000001;0.000000;0.000000;431.7288|
|1980-01-01;17:00;302.30;61.87;1004.49;1.14;115.56;0.000003;0.000000;0.000000;201.1529|
|1980-01-01;18:00;301.09;68.12;1004.99;1.33;133.56;0.000000;0.000000;0.000000;22.8475|
|1980-01-01;19:00;300.13;70.86;1005.70;1.74;152.70;0.000001;0.000000;0.000000;0.0000|
Why cannot the graph display with the code below?
void tttree(const char *dirname=“Kabala.csv”)
{

TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
   dir.ReplaceAll("Elijah.C","");
   dir.ReplaceAll("/./","/");

// char line[3000];
// in.getline(line,1000);
TFile *f = new TFile(“dirname.root”,“RECREATE”); //create file data.root
TTree *tree = new TTree(“tree”,“data from ascii file”);
Double_t nlines = tree->ReadFile(Form(dirname,dir.Data()),“pa:pb:pc”);//create tree with
gROOT->SetStyle(“Plain”);
gStyle->SetOptStat(1111);
gStyle->SetOptFit(1111);
TCanvas *c = new TCanvas(“c”, “General Plots1”,1400,800);
TMultiGraph * mg = new TMultiGraph();
tree->Draw(“pc:pa”);
TGraph *gr = new TGraph(tree->GetSelectedRows(),tree->GetV2(), tree->GetV1());
gr->SetName(“myGraph”);
gr->Draw();
gr->SetMarkerColor(kRed);
gr->SetMarkerStyle(21);
gr->SetLineColor(kRed);

   mg->Add(gr);
mg->Draw("ab");
mg->GetXaxis()->SetTitle("number of data between 2000-2013");
mg->GetYaxis()->SetTitle("Aerosol Optical Depth");

c->Update();
c->Modified();

}

What is the error message you get?

Isn’t it obvious that the input data file is NOT a “comma-separated values (CSV)” file.

Error in TGraphPainter::PaintGraph: illegal number of points (0)

Error in TGraphPainter::PaintGraph: illegal number of points (0)

Thank you for your quick response. Please how do I plot this kind of data. It is not displaying with error ’ Error in TGraphPainter::PaintGraph: illegal number of points (0)

Error in TGraphPainter::PaintGraph: illegal number of points (0)’

Your kind assistance would be much appreciated

{
  // Note: make sure that the input data file ("Kabala.csv") is a properly
  // formatted "comma-separated values (CSV)" file.
  // If the "Kabala.csv" file has lines in form "|...;...;...|", first run:
  // sed -i -e '{s/|//g;s/;/,/g}' Kabala.csv # no "|", ";" changed into ","
  TTree *t = new TTree("t", "my magic tree");
  t->ReadFile("Kabala.csv", "date/C:time:v1/D:v2:v3:v4:v5:v6:v7:v8:v9");
  t->Print();
  t->Scan("*");
}

Indeed! I don’t know how I missed that. Thanks.

See what it gave me


*Tree :tree : data from ascii file *
*Entries : 0 : Total = 291 bytes File Size = 0 *

  •    :          : Tree compression factor =   1.00                       *
    


  • Row *