tab-delimited-text

How to properly read columns from text file

回眸只為那壹抹淺笑 提交于 2019-12-12 21:04:29
问题 Im trying to read data from a text file and loading it into a dataset but the different columns as in the image below are coming as just one long column. I want to return the data as 7 columns (in the same way as its appearing in the image below). This is the code am using, 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()

StreamReader with tab delimited text file

我怕爱的太早我们不能终老 提交于 2019-12-12 10:08:34
问题 I have a similar requirement to this post... Populate Gridview at runtime using textfile Where I want to read a text file with StreamReader and populate a DataTable with the data in the file, however I'm not sure how to implement a split() with a tab. Could anybody point me in the right direction, please? 回答1: You can try this: DataTable table = new DataTable(); table.Columns.Add("col1"); table.Columns.Add("col2"); table.Columns.Add("col3"); var lines = File.ReadAllLines(@"Data.txt").ToList()

StreamReader with tab delimited text file

时光总嘲笑我的痴心妄想 提交于 2019-12-06 06:39:33
I have a similar requirement to this post... Populate Gridview at runtime using textfile Where I want to read a text file with StreamReader and populate a DataTable with the data in the file, however I'm not sure how to implement a split() with a tab. Could anybody point me in the right direction, please? You can try this: DataTable table = new DataTable(); table.Columns.Add("col1"); table.Columns.Add("col2"); table.Columns.Add("col3"); var lines = File.ReadAllLines(@"Data.txt").ToList(); lines.ForEach(line => table.Rows.Add(line.Split((char)9))); I presumed that rows are delimited by newline

reading and parsing a TSV file, then manipulating it for saving as CSV (*efficiently*)

强颜欢笑 提交于 2019-11-29 19:48:27
My source data is in a TSV file, 6 columns and greater than 2 million rows. Here's what I'm trying to accomplish: I need to read the data in 3 of the columns (3, 4, 5) in this source file The fifth column is an integer. I need to use this integer value to duplicate a row entry with using the data in the third and fourth columns (by the number of integer times). I want to write the output of #2 to an output file in CSV format. Below is what I came up with. My question: is this an efficient way to do it? It seems like it might be intensive when attempted on 2 million rows. First, I made a sample

reading and parsing a TSV file, then manipulating it for saving as CSV (*efficiently*)

故事扮演 提交于 2019-11-27 09:34:56
问题 My source data is in a TSV file, 6 columns and greater than 2 million rows. Here's what I'm trying to accomplish: I need to read the data in 3 of the columns (3, 4, 5) in this source file The fifth column is an integer. I need to use this integer value to duplicate a row entry with using the data in the third and fourth columns (by the number of integer times). I want to write the output of #2 to an output file in CSV format. Below is what I came up with. My question: is this an efficient way