| 
|  | Chaim6 2014-01-30 10:43:25
 
 
 
 |  | 
	 When downloading Morningstar data, it is common to have missing information. For example, see 2009 Cap Spending for Toyato in http://financials.morningstar.com/ratios/r.html?t=7203®ion=jpn&culture=en-US&ownerCountry=USA. It's obvious that the number is not 0. Yet the C# parser must initialize all fields to 0 in order for the parser to work properly. A blank field gets converted to 0 automatically. I would like to set it to NaN. Is that possible?
 Thanks.
 
 |  |  | 
| 
|  | QuantShare 2014-01-30 20:03:05
 
 
  0   
 
 |  | 
	 Yes, in the POST-Script, check for zeros and updates that the field to: double.NaN
      
 
 
 |  |  | 
| 
|  | Chaim6 2014-01-31 05:18:32
 
 
  0   
 
 |  | 
	 Okay, here's what I tried in the Post-Script:
 for (int iRow = 1; iRow < Data.Rows.Length; iRow++)
 for (int iCol = 1; iCol < Data.Rows[iRow].Data.Length; iCol++)
 if (unchecked((double)Data.Rows[iRow].Data[iCol]) == 0)
 Data.Rows[iRow].Data[iCol] = Double.NaN;
 
 It compiles ok, but I get a Post-Script execution error:
 "Specified cast is not valid."
 
 How do I fix this code?
 
 Thanks.
 
 
 
 |  |  | 
| 
|  | QuantShare 2014-01-31 13:23:51
 
 
  0   
 
 |  | 
	 Try this:
 for (int iRow = 0; iRow < Data.Rows.Length; iRow++)
 for (int iCol = 0; iCol < Data.Rows[iRow].Data.Length; iCol++)
 {
 object obj = Data.Rows[iRow].Data[iCol];
 if(obj is double && (double)obj == 0)
 {
 Data.Rows[iRow].Data[iCol] = Double.NaN;
 }
 }
 
 
 
 
 
 |  |  | 
| 
|  | Chaim6 2014-01-31 20:55:53
 
 
  0   
 
 |  | 
	 That put me on the right track. I ended up using:for (int iRow = 0; iRow < Data.Rows.Length; iRow++)
 for (int iCol = 0; iCol < Data.Rows[iRow].Data.Length; iCol++)
 {
 double d;
 if(double.TryParse(Convert.ToString(Data.Rows[iRow].Data[iCol]), out d) && d == 0)
 {
 Data.Rows[iRow].Data[iCol] = Double.NaN;
 }
 }
 because the 0's for some reason were not of type double. Thanks.
 
 
 
 |  |  | 
| 
 |