# Convert a csv file into ROOT format

**URL:** <https://root-forum.cern.ch/t/convert-a-csv-file-into-root-format/33217>\
**Category:** Newbie\
**Created:** [March 18, 2019, 7:14pm UTC](https://root-forum.cern.ch/t/convert-a-csv-file-into-root-format/33217 "2019-03-18T19:14:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addy369](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@addy369](https://root-forum.cern.ch/u/addy369)\
**Post date:** [March 18, 2019, 7:14pm UTC](https://root-forum.cern.ch/t/convert-a-csv-file-into-root-format/33217/1 "2019-03-18T19:14:05Z")

</div>

I am a complete newbie to the root framework and would really appreciate if someone could tell me how to convert a csv(or any data file) into root format

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [March 18, 2019, 8:59pm UTC](https://root-forum.cern.ch/t/convert-a-csv-file-into-root-format/33217/2 "2019-03-18T20:59:49Z")

</div>

Hi,

you can use [RDataFrame](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) and [CSV data source](https://root.cern/doc/master/classROOT_1_1RDF_1_1RCsvDS.html).  
[This](https://root.cern/doc/master/df014__CSVDataSource_8C_source.html) is a more complete example.  
Basically, you’ll have to perform the following steps:

```auto
auto fileName = "myFile.csv";
auto rdf = ROOT::RDF::MakeCsvDataFrame(fileName);
rdf.Snapshot("myTree", "myFile.root");

```

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![phy.vijayraj](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phy.vijayraj/32/18580_2.png) [@phy.vijayraj](https://root-forum.cern.ch/u/phy.vijayraj)\
**Post date:** [May 13, 2019, 1:56pm UTC](https://root-forum.cern.ch/t/convert-a-csv-file-into-root-format/33217/3 "2019-05-13T13:56:51Z")

</div>

Thankyou very much respected D. I also would like to know conversion of myfile.CNF to myfile.root  
Do I follow the same steps. For the sake I attach herewith a file in .CNF format. Please have a look. Waiting for the suggestions and comments.  
Much Respect[files.tar.gz](https://root-forum.cern.ch/uploads/default/original/3X/8/c/8c347d94a5ac4fe47a349985bdaf0e58d32f4ce2.gz) (12.6 KB)

VRS
