@@ -13,23 +13,23 @@ Using the parsers module, we can load file data into simple and easy-to-work-wit
1313 Our goal will be to extract the data, and the parameters listed in the header, from this file and
1414 load it into our program.
1515
16- 2) To get the data table, we will use the ``loadData `` function. The default behavior of this
16+ 2) To get the data table, we will use the ``load_data `` function. The default behavior of this
1717 function is to find and extract a data table from a file.
1818
1919.. code-block :: python
2020
21- from diffpy.utils.parsers.loaddata import loadData
22- data_table = loadData (' <PATH to data.txt>' )
21+ from diffpy.utils.parsers import load_data
22+ data_table = load_data (' <PATH to data.txt>' )
2323
2424 While this will work with most datasets, on our ``data.txt `` file, we got a ``ValueError ``. The reason for this is
2525due to the comments ``$ Phase Transition Near This Temperature Range `` and ``--> Note Significant Jump in Rw <-- ``
2626embedded within the dataset. To fix this, try using the ``comments `` parameter.
2727
2828.. code-block :: python
2929
30- data_table = loadData (' <PATH to data.txt>' , comments = [' $' , ' -->' ])
30+ data_table = load_data (' <PATH to data.txt>' , comments = [' $' , ' -->' ])
3131
32- This parameter tells ``loadData `` that any lines beginning with ``$ `` and ``--> `` are just comments and
32+ This parameter tells ``load_data `` that any lines beginning with ``$ `` and ``--> `` are just comments and
3333more entries in our data table may follow.
3434
3535Here are a few other parameters to test out:
@@ -39,30 +39,30 @@ Here are a few other parameters to test out:
3939
4040.. code-block :: python
4141
42- loadData (' <PATH to data.txt>' , comments = [' $' , ' -->' ], delimiter = ' ,' )
42+ load_data (' <PATH to data.txt>' , comments = [' $' , ' -->' ], delimiter = ' ,' )
4343
4444 returns an empty list.
4545 * ``minrows=50 ``: Only look for data tables with at least 50 rows. Since our data table has much less than that many
4646 rows, running
4747
4848.. code-block :: python
4949
50- loadData (' <PATH to data.txt>' , comments = [' $' , ' -->' ], minrows = 50 )
50+ load_data (' <PATH to data.txt>' , comments = [' $' , ' -->' ], minrows = 50 )
5151
5252 returns an empty list.
5353 * ``usecols=[0, 3] ``: Only return the 0th and 3rd columns (zero-indexed) of the data table. For ``data.txt ``, this
5454 corresponds to the temperature and rw columns.
5555
5656.. code-block :: python
5757
58- loadData (' <PATH to data.txt>' , comments = [' $' , ' -->' ], usecols = [0 , 3 ])
58+ load_data (' <PATH to data.txt>' , comments = [' $' , ' -->' ], usecols = [0 , 3 ])
5959
60- 3) Next, to get the header information, we can again use ``loadData ``,
60+ 3) Next, to get the header information, we can again use ``load_data ``,
6161 but this time with the ``headers `` parameter enabled.
6262
6363.. code-block :: python
6464
65- hdata = loadData (' <PATH to data.txt>' , comments = [' $' , ' -->' ], headers = True )
65+ hdata = load_data (' <PATH to data.txt>' , comments = [' $' , ' -->' ], headers = True )
6666
6767 4) Rather than working with separate ``data_table `` and ``hdata `` objects, it may be easier to combine them into a single
6868 dictionary. We can do so using the ``serialize_data `` function.
@@ -116,8 +116,8 @@ The returned value, ``parsed_file_data``, is the dictionary we just added to ``s
116116
117117.. code-block :: python
118118
119- data_table = loadData (' <PATH to moredata.txt>' )
120- hdata = loadData (' <PATH to moredata.txt>' , headers = True )
119+ data_table = load_data (' <PATH to moredata.txt>' )
120+ hdata = load_data (' <PATH to moredata.txt>' , headers = True )
121121 serialize_data(' <PATH to moredata.txt>' , hdata, data_table, serial_file = ' <PATH to serialdata.json>' )
122122
123123 The serial file ``serialfile.json `` should now contain two entries: ``data.txt `` and ``moredata.txt ``.
0 commit comments