1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| while (!MonFichier.EndOfStream) //tant que je ne suis pas à la fin du fichier
{
string ligne = MonFichier.ReadLine(); // lecture d'une ligne
tabCSV = ligne.Split(';'); // récupération du tableau de string avec chaque contenu entre ;
string[] FormatsDates = new string[8] { "dd/MM/yyyy", "d/M/yyyy", "dd/MM/yyyy HH:mm:ss.fff", "d/M/yyyy HH:mm:ss.fff", "dd/MM/yyyy HH:mm:ss", "d/M/yyyy HH:mm:ss", "dd/MM/yyyy HH:mm", "d/M/yyyy HH:mm" };//formats possible de date
double date = DateTime.ParseExact(tabCSV[0], FormatsDates, null, System.Globalization.DateTimeStyles.None).ToOADate();
index = index - NbChamps + 1;
for (int y = 1; y < NbChamps; y = y + NombreDeChampParParametre)
{
try
{
Valeur = Convert.ToDouble(tabCSV[y], CultureInfo.InvariantCulture);
}
catch
{
break;
}
MesList[index].Add(new MyClassSerie { myDate = date, myValeur = Valeur });
index++;
}
} |
Partager