DatemTime reading immposible.

Mar 16, 2014 at 10:35 AM
Edited Mar 16, 2014 at 10:37 AM
Hello, i have file with following content:
TimeStamp;Val;
2012-12-18 00:00;17,5
2012-12-18 00:15;18,2
2012-12-18 00:30;18,2
2012-12-18 00:45;17,5
I open this file this way:
engine.Evaluate("data<-read.csv('C:/data.csv', header=T, sep=\";\", dec=\",\")");
and then try to read data this way:
DataFrame df = engine.GetSymbol("data").AsDataFrame();
                for (int rowIndex = 0; rowIndex < df.RowCount; rowIndex++)
                {
                    for (int colIndex = 0; colIndex < df.ColumnCount; colIndex++)
                    {
                       object time2 = df[rowIndex, colIndex];
                       string time = df[rowIndex, colIndex].ToString();
                    }
                    Console.Write(Environment.NewLine);
                }
but time is formated into numeric values like 1,2,3,4 ...
But before converstion when I look into df DataFrame, there seems be right value look:
Image

and after conversion
Image

Any help how to read correct time value ? I think that RdotNet or R engine, is created indexing table and putting this values there listing here only ids to these values. like if I would have few times the same value in my TimeStamp column, there would be the same ids.
Developer
Mar 17, 2014 at 12:17 AM
It is possible. A similar question was already asked in (this post)[https://rdotnet.codeplex.com/discussions/531632]

For your particular case:
# note: sample code using IronPython
e.Evaluate("x <- read.csv('c:/tmp/testdf.csv', header=T)")
e.Evaluate('str(x)')
# Simplest solution:
datesChar = e.Evaluate('as.character(x[,1])').ToArray()

# Or, if you insist in doing things in c#
df = e.Evaluate("x")
df = df.AsDataFrame()
dates = df[0]
indices = dates.AsInteger().ToArray()
levels = dates.AsFactor().GetFactors()
# Then reconstruct the array of strings by indexing and factors
Where the file contains:
Date,a,b,c,d
1984-01-24,1,6,4,2.3
1984-01-25,1,6,4,2.3
1984-01-26,1,6,4,2.3