I have a huge php file that contains a number of arrays
<?php
$quadrature_weights = array();
$quadrature_weights[2] = array(
1.0000000000000000,
1.0000000000000000);
$quadrature_weights[3] = array(
0.8888888888888888,
0.5555555555555555,
0.5555555555555555);
$quadrature_weights[4] = array(
0.6521451548625461,
0.6521451548625461,
0.3478548451374538,
0.3478548451374538);
?>
The real file contains 64 quadrature_weights
and the actual number of decimals of the numbers inside the arrays is in the order of 200 (I have reduced the number here for readability).
I would like to load this file into python and determine how many decimals to keep. Lets say i decide to keep 4 decimals the output should be a dictionary (or some other container) like this
quadrature_weights = {
2: [1.0000,
1.0000],
3: [0.8888,
0.5555,
0.5555],
4: [0.6521,
0.6521,
0.3478,
0.3478]
}
I am not familiar with php and quite frankly I have no idea how to do this. I suppose it would be possible read every single line and then do some sort of "decoding" manually but I was really hoping to avoid that.