2
텍스트 파일에서 데이터를 읽고 데이터 세트로로드하려고 시도했지만 아래 이미지에서와 같이 다른 열이 하나의 긴 열로 표시됩니다. 데이터를 7 개의 열로 반환하고 싶습니다 (아래 이미지에 나타나는 것과 같은 방식으로).텍스트 파일에서 열을 올바르게 읽는 방법
이 코드를 사용하고있다,
public DataSet LoadTxtFile(int numberOfRows)
{
DataSet ds = new DataSet();
//try
//{
// Creates and opens an ODBC connection
string strConnString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + this.dirCSV.Trim() + ";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string sql_select;
OdbcConnection conn;
conn = new OdbcConnection(strConnString.Trim());
conn.Open();
//Creates the select command text
if (numberOfRows == -1)
{
sql_select = "select * from [" + this.FileNevCSV.Trim() + "]";
}
else
{
sql_select = "select top " + numberOfRows + " * from [" + this.FileNevCSV.Trim() + "]";
}
//Creates the data adapter
OdbcDataAdapter obj_oledb_da = new OdbcDataAdapter(sql_select, conn);
//Fills dataset with the records from CSV file
obj_oledb_da.Fill(ds, "csv");
//closes the connection
conn.Close();
//}
//catch (Exception e) //Error
//{
//MessageBox.Show(e.Message, "Error - LoadCSV",MessageBoxButtons.OK,MessageBoxIcon.Error);
//}
return ds;
}
어떤 언어가 Java/C#과 비슷하지만 적절하게 태그를 지정해야합니다. –
귀하의 이름은 그것이 C# –