obtenu la réponse:
je l'ai fait avec succès l'analyse de mon fichier CSV à l'aide du code ci-dessous:
_nNrRowsProccessed = 0;
string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="+ConfigurationManager.AppSettings["csvFolder"]+";";
OdbcConnection conn = new OdbcConnection(connectionString);
try
{
conn.Open();
string strFileName = ConfigurationManager.AppSettings["csvFileName"];
string strSQL = "Select * from " + strFileName;
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = conn;
cmd.CommandText = strSQL;
cmd.CommandType = CommandType.Text;
OdbcDataReader reader = cmd.ExecuteReader();
string strLine = null;
MasterCalendar_DB.OpenMySQLConnection();
while (reader.Read())
{
// insert data into mastercalendar
strLine = reader[0].ToString();
string[] arLine = strLine.Split(';');
string strAgencyPropertyID = arLine[0];
DateTime dt = DateTime.Parse(arLine[1]);
Int64 nDate = (Int64)Util.ConvertToUnixTimestamp(dt);
String strAvailability = (arLine[2]);
_nNrRowsProccessed++;
MasterCalendar_DB.Insert(strAgencyPropertyID, nDate, strAvailability);
}
}
finally
{
conn.Close();
MasterCalendar_DB.CloseMySQLConnection();
}
vous devez également ajouter le code suivant sous le tag Configurations dans votre fichier web.config:
<appSettings> <add key="csvFileName" value="<file_name>.csv" /> <add key="csvFolder" value="<filePath>"/> </appSettings>
Hope this helps quelqu'un :)
Très proche de http://stackoverflow.com/questions/4748082/how-to-download-the-csv-file-in -mon-site-d'-autre-serveur-web. Seulement quelques mots différents. –
L'autre article concerne le téléchargement et non l'analyse. –
cela n'a rien à voir avec asp.net, il s'agit seulement d'analyser. –