 |
|
 |
This is very helpful, only I my txt file doesn't contain column headings. How would you modify this to omit column headings?
|
|
|
|
 |
|
 |
Hey, I have a upload control sending data from my tab delimited file into memory. What I want to do is have this helper class use the stream instead of a file. I can't upload any files into the server so this has to be done in memory. Here's my code:
using System;
using System.Data;
using TestTextToDataSet;
public partial class blah : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
String ext = System.IO.Path.GetExtension(FileUpload1.FileName).ToUpper();
String content = System.Text.Encoding.ASCII.GetString(FileUpload1.FileBytes);
DataSet ds = TextToDataSet.Convert(FileUpload1.FileName, "MyDataSet", "\t");
}
}
|
|
|
|
 |
|
 |
hi
this is a nice article
but I need to fill my gridview(kryptongridview) with data but I can't by just putting the datasource of the gridview to the dataset...
there is a solution to this???
Dim OpenFileDialog As New OpenFileDialog()
OpenFileDialog.Filter = "Txt files|*.txt"
If OpenFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim dataSet As Data.DataSet = TextToDataSet.Convert(OpenFileDialog.FileName, "taleName", "\t")
GR_Matrix.DataSource = dataSet
GR_Matrix.DataMember = "taleName"
End If
nice to meet you
|
|
|
|
 |
|
 |
I have get the solution...
my problem was my conversion to vb.net code...
columns and rows was not in good places...
but when using the code I had written it is working fine
nice to meet you
|
|
|
|
 |
|
 |
I think that parameter name 'tablename' means the data table. But the type of that is string. How can I put the data table name like parameter.
|
|
|
|
 |
|
 |
The column name should be trimmed of white space before being added to the table. If your code elsewhere references ' Column_Name' rather than 'Column_Name', you will get a 'Column doesn't belong to table Blah' message. This will have you scratching your head for a while.
|
|
|
|
 |
|
 |
is it possible to define your delimiter in the DataSet ds = TextToDataSet.Convert(
"c:\test.txt", "MyNewTable", "????");
so that it takes any amount of white spaces as a delimiter and the amount changes from column to column in the file and from row to row aswell?
|
|
|
|
 |
|
 |
i added one line here to remove the empty rows.
foreach (string r in rows)
{
//Split the row at the delimiter.
if (r.Trim().Length > 0)
{
string[] items = r.Split(delimiter.ToCharArray());
//Add the item
result.Tables[TableName].Rows.Add(items);
}
}
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
|
|
|
|
 |
|
 |
If you are using TextToDataSet.Convert on a file that was just uploaded with the asp.net FileUpload control, you will want to dispose of the StreamReader to prevent aspnet_wp.exe from locking the file. If you don't you will receive this message: "The process cannot access the file '' because it is being used by another process." Hope this helps someone.
|
|
|
|
 |
|
 |
Great article! I am trying to take the data from a csv file and bind it to the ReportViewer control. I can fill the table using your article; however, I can't seem to get the data table bound to the ReportViewer control. Here's what I have.
I am using ASP.NET 2.0. I have created a data set called Stocks data table called Data and put it in the App_Code folder. I am filling the data table from data in a csv file located on the web. I am populating the data table with the following code. This code works because I checked the record count and it shows 21 records for the Data data table.
public static DataSet Convert()
{
WebClient Client = new WebClient();
Stream myStream = Client.OpenRead("http://mysite.com/table.csv");
StreamReader myStreamReader = new StreamReader(myStream);
Stocks myStocks = new Stocks();
string line = myStreamReader.ReadLine();
string allData = myStreamReader.ReadToEnd();
string[] rows = allData.Split("\r\n".ToCharArray());
foreach (string r in rows)
{
string[] items = r.Split(",".ToCharArray());
myStocks.Tables["Data"].Rows.Add(items);
}
return myStocks;
}
I am trying to bind the data in this table to a report. I added a report to my project and selected the fields from the data table. I then added a ReportViewer control to the web form. I’m not sure how to configure the ObjectDataSource that is added to the web form after the ReportViewer control is added. It firsts asks to select business object. I have the following options. I’m not sure what to select.
Stocks
Stocks + DataTable
Stocks + DataRow
Stocks + DataRowChangeEvent
Stocks + DataRowChangeEventHandler
Next I need to define a data method. Not sure what option to select. I just want to bind the report to the data table and return the rows.
Any help would be appreciated. Thanks.
Weste
Weste
|
|
|
|
 |
|
 |
just need a little more help with my beginners project, please.
I have a large file in the following CSV format
"71415","535","200","5364564","0","0","0","0","0","0","0","0","0"
I have used the code from this article to place the data in a datagrid.
Just wondering , What is the easiest way to strip out all the quotation marks during the parsing ?
Any help would be appreciated, thanks in advance.
|
|
|
|
 |
|
 |
Well, the easiest way is to do
string ColumnValue = ColumnValue.ToString().Replace("""", "");
but you need to realize that if the data has a quotation mark in it, this line will replace those too!
Hope it helps.
Dave-O
|
|
|
|
 |
|
 |
Thanks Dave
//what i actually did was at the output of the streamreader.
AllData = AllData.Replace('"', ' ');
This did the same thing.
How would you approach deleting a dataSet, dataTable column , after checking to see if it contained all Zeros ?
There seems to be a lot of complicated approaches to do a simple thing, whats your opinion.
|
|
|
|
 |
|
 |
For the benefit of myself and other absolute beginners, could someone please demonstrate how this class is used to return the imported data to say a blank SQL server database and how it creates the structure as this happens.
Thanks in advance
|
|
|
|
 |
|
|
 |
|
 |
Thanks for that.
|
|
|
|
 |
|
 |
Thanks for the wonderful article Dave,
How do I write back the changes to the same text file. I want to use .txt file as my database storage, instead of SQL Server or Access.
I am thinking of writing an application that will not use SQL, Access, nor any database apps.
This is because, I want my application to be able to run on any PC - including those that do not have SQL Server or Access.
------------------------------------------------
Paul Chin
|
|
|
|
 |
|
 |
Have you considered SQL Server Compact?
Might be a better long term fit, esp if your doing a lot of data manipulation.
|
|
|
|
 |
|
 |
Can someone possibly provide an example form that shows some of the data from a text file. I'm not quite certain how this is being done. I'm using VS2005.
TIA
|
|
|
|
 |
|
 |
For large text file of size 155,966KB , getting an error as
'unhandled exception of type 'Sysyem.outofmemoryException' occured in mscorlib.dll. What's the max size we can use?
Thanks in advance
Manoj
|
|
|
|
 |
|
 |
There is problem with big file as this code reads the whole file in one time.
Is there any way to read some lines from a text file at a time?
|
|
|
|
 |
|
 |
Yes, you would need to read the bytes from the stream, convert to the bytes to a string, and split at the line ends as you go. The only problem with that is that you don't know how many bytes are in each line more than likely, so you will always have the last item in the split to carry over to the next cycle, because it will more than like be the start, but not the whole line.
Dave - O
P.S. Goto CoderForRent.com for freelance work. It's all free!
-- modified at 19:00 Monday 29th May, 2006
|
|
|
|
 |
|
 |
Hi All,
I have used the code which is given in "Fill a DataSet from delimited Text Files". I am creating a tab delimited file using (batch file) MSSQL bcp command like
bcp "Select * from sysobjects" queryout %log%.tb2 -c -S%server% -T
here -c Performs the bulk copy operation using a character data type. Now I want to import the same file and show in data grid. But I am not getting those many columns in datagrid. Please help me.......
Thanks in advance..
mamidi
|
|
|
|
 |
|
 |
The first line must be column names. I am not really familiar with the SQL part of what you are doing here, sorry.
Dave-O
Dave - O
programmerfreelance.net
|
|
|
|
 |
|
 |
i will not have column names in first line. Direct loading the data into Data Grid.
mamidi
|
|
|
|
 |