R
rob
I have to read a csv file. In order to avoid all the hassle with the
parsing (some items are in quotes, others are not, some have
quotes/comas in the items themselves, etc) I simply use odbc. The code
is shown bellow. The problem is that the source is actually a string (a
csv file downloaded from the internet via
WebResponse->GetResponse->GetResponseStream->ReadToEnd). So in order to
read it through odbc I have to store the string to a file just so that
I can pass the file to the ctor of OdbcConnection. Is there a way I can
avoid having to create a temporary file?
Thanks
connectionString = @"Driver={Microsoft Text Driver (*.txt;
*.csv)};DBQ=" + Path.GetDirectoryName(filename);
connection = new OdbcConnection(connectionString);
connection.Open();
command = new OdbcCommand("Select * FROM " +
Path.GetFileName(filename), connection);
reader = command.ExecuteReader();
parsing (some items are in quotes, others are not, some have
quotes/comas in the items themselves, etc) I simply use odbc. The code
is shown bellow. The problem is that the source is actually a string (a
csv file downloaded from the internet via
WebResponse->GetResponse->GetResponseStream->ReadToEnd). So in order to
read it through odbc I have to store the string to a file just so that
I can pass the file to the ctor of OdbcConnection. Is there a way I can
avoid having to create a temporary file?
Thanks
connectionString = @"Driver={Microsoft Text Driver (*.txt;
*.csv)};DBQ=" + Path.GetDirectoryName(filename);
connection = new OdbcConnection(connectionString);
connection.Open();
command = new OdbcCommand("Select * FROM " +
Path.GetFileName(filename), connection);
reader = command.ExecuteReader();