|
Hi All,
I've got an application that opens a csv file and save the data in the file to a Database. When the app reads the file it only reads the second column my problem is, the format of the date in the file has changed the date use to be like, 20081019 now it has changed to "October 26, 2008",.
The file is like Day,Visitors
"October 26, 2008",356 where day is the date. Now the app reads year 2008 when i want it to read the Visitors 356.
Please can you help me
Regards,
Ndeza
modified on Tuesday, October 28, 2008 4:52 AM
|
|
|
|
|
Who has the time to go through all that rubbish? Please post only "relevant" code, if required. Read the guidelines before posting a question.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
Not sure I understand... but you're saying the CSV actually has the enclosing quotes? Then it is the app which fails to parse properly.
There are libraries that handle CSV files, you're better off using one of them.
Cheers,
Vıkram.
"You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.
|
|
|
|
|
Hello friends
Can Any One tell me how can I read or write a specific line from a txt file.
Suppose using StreamReader or Straemwritter.
Thank in Advance
Johnny
|
|
|
|
|
Files are not line based (or even character based). You have to read the lines before to get to the correct position in the file.
To change a line you have to write that line and rewrite all the lines that follows it.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
What about using LINQ to read the specific line, writing is another story. I agree with Guffa about the writing each line again.
take the following into consideration: read all customers who live in UK.
var query =
from c in
(from line in File.ReadAllLines(filePath)
let customerRecord = line.Split(‘,’)
select new Customer()
{
Firstname = customerRecord[0],
Lastname = customerRecord[1],
JobTitle = customerRecord[2],
City = customerRecord[3],
Country = customerRecord[4]
})
where c.Country == "UK"
select c;
Regards,
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: What about using LINQ to read the specific line
With the drawback that it always reads the entire file, even if you want a line at the beginning of the file.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: With the drawback that it always reads the entire file
This is true, on the other hand you can read it, once and perform various LINQ queries on it.
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
What does the text book say?
|
|
|
|
|
In my C# Application program, I have two DataGridViews which are not bound to any data source. I have coded them so that the user is allowed to drag and drop data between the two DGVs as well as within them.
So, when a data item in a cell is dragged and dropped on another cell, the data on the original is deleted - that is set to null.
The problem is, when I do that, after dropping, it automatically select the last cell (the one in which I just set the value to null).
How do I get that cell to be NOT selected?
Here is my code:
dgvSchedule.DoDragDrop(text, DragDropEffects.Copy);
if (bDataDrop == true)
{
dgvSchedule.Rows[info.RowIndex].Cells[info.ColumnIndex].Value = null;
dgvSchedule.Rows[info.RowIndex].Cells[info.ColumnIndex].Selected = false;
bDataDrop = false;
}
There, right after I set the value to null, I set the 'selected' property to false, but despite that it still selects that.
Please HELP!
|
|
|
|
|
try calling the refresh method of datagridview after you are done.
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
Nope mate, it doesn't work.
|
|
|
|
|
How do I enable freehand drawing on WPF or WPF browser application?
|
|
|
|
|
control.EnableFreehandDrawing = true;
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Well, I'd start off with an InkCanvas if I were you - also, I'd look at posting this in the WPF forum, rather than the C# forum.
|
|
|
|
|
Hai friends,
I want to automate MSProject applicaton. Using early binding it is possible to me. But applying late binding i can't. Pls help me to automate mpp using latebinding...
When try to automate it gives an error : Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME
Thanks in advance,
Praji
|
|
|
|
|
Hi,
I using visual studio 2003 with c# script and microsoft office excel 2003. I had add refrence microsoft office excel 11.0 object library. But when i start to run that show the error:
Excel.Application excelapp = new Excel.Applicationclass();
Can give me some idea?
|
|
|
|
|
Can you post here exception message ?
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
/*using Excel;
public Excel.Application excel_app;
string pathfile = @"C:\Inetpub\wwwroot\data\test.xls";
excel_app = new ApplicationClass();
Excel.Workbook excel_book = excel_app.Workbooks.Open(pathfile,0,true,5,"","",true,Excel.XlPlatform.xlWindows,"\t",false,false,0,true,1,0);
Excel.Worksheet excel_wsheet = (Excel.Worksheet)excel_book.ActiveSheet;
string firstName = ((Excel.Range)excel_wsheet.Cells[1,1]).Value2.ToString();
string lastName = ((Excel.Range)excel_wsheet.Cells[1,2]).Value2.ToString();
.....
.....
....*/
|
|
|
|
|
i am rather new to C#, i am switching from java, i followed through with a baisic c# screensaver tutorial, then i tried to add a picture and make it bounce around the screen. i added a picture box set to a picture(LM), i made a loop to make it move, then tried to figure out how to start it, i added it the end of load. this is probably extremely noobish and i am sorry,but if someone would help thatd be great
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ScreenSaver
{
public partial class Form1 : Form
{
private int screenNumber;
private Point MouseXY;
int curX = 1;
int curY = 1;
Boolean running = true;
public Form1(int screen)
{
screenNumber = screen;
InitializeComponent();
this.run();
}
private void form1_Load(object sender, System.EventArgs e)
{
this.Bounds = Screen.AllScreens[screenNumber].Bounds;
Cursor.Hide();
TopMost = true;
}
private void onMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (!MouseXY.IsEmpty)
{
if(MouseXY != new Point(e.X,e.Y))
{
running = false;
}
if(e.Clicks >0)
{
running = false;
}
}
MouseXY = new Point(e.X, e.Y);
}
public void run()
{
while (running)
{
loopMove();
Thread.Sleep(1000);
}
Close();
}
private void LM_Click(object sender, EventArgs e)
{
}
private void changeLMY(int y)
{
LM.Left += y;
}
private void changeLMX(int x)
{
LM.Top += x;
}
private void loopMove()
{
int fX = this.Top;
int fY = this.Left;
if (LM.Top >= fX - 300)
curX = -1;
if (LM.Top == 0)
curX = 1;
if (LM.Left >= fY - 300)
curY = -1;
if (LM.Left == 0)
curY = 1;
changeLMX(curX);
changeLMY(curY);
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ScreenSaver
{
static class Program
{
[STAThread]
static void Main(String[] args)
{
if (args.Length > 0)
{
if (args[0].ToLower().Trim().Substring(0, 2) == "/c")
{
}
else if(args[0].ToLower()== "/s")
{
}
else if (args[0].ToLower() == "/p")
{
}
}
else
{
for (int i = Screen.AllScreens.GetLowerBound(0); i <= Screen.AllScreens.GetLowerBound(0); i++)
{
System.Windows.Forms.Application.Run(new Form1(i));
}
}
}
|
|
|
|
|
|
Why not use the Project|Properties|Resources and just drag and drop onto there? Then you can just use Properties.Resources.yourimagewithoutextension
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
hy everyone!
we do have a problem:
we coded a webpart which allows searching and printing of document in a document store. you search for files, you are able to display them and you are able to print them.
therefor we wrote a printservice, which fetches the file from the store and sends them to the spooler and printer respectively. that works fine. afterwords we update the database to set some fields, indicating the file was already printed.
when using a little amount of files it works file, but the bigger the collection of file is, the more problems appear. meaning, when selecting around 100 files with around 1 MB each, a thread abort exception is thrown. if there are just 40 files, no exception is thrown.
and to complicate the situation: if you repeat printing the same files lets say for 10 times, it works in lets say 7 tries and fails in 3 tries. sometimes it even works in all tries or it fails more often. its like guessing numbers in a lottery.
but it does not throw the thrad abort exception during printing, it throws the exception when returning to the code of the webpart where the printing was invoked at. meaning we wrote a printbuttonclick event-function which invokes the printservice with the file ids, and some other properties. and when returning the exception is thrown.
we tried to change the timeout of the printservice indefinite (-1), we also tried to change the code to get as much performance as possible, we also did a lot of garbage collection etc. but we can't get rid of this exception.
we also have already been googling for this incident, but nothing really solved our problem. we were just able to send more files until it is likely to be thrown.
printing around 100 files could take up to 1-2 minutes, so i guess maybe this could take to long and the thread times out when returning.
does anyone have an idea of
1) where to start to get an idea how to get rid of this error (maybe a page of hints we haven't already been to etc.)
2) how to get rid of this exception. maybe one of you has already encountered anything similar.
thanks for any hints and ideas.
if you do need some further infos for understanding or to get an idea of how to solve it, just feel free to ask.
thanks!
stephan.
|
|
|
|
|
The only thing that the ThreadAbortException is used for, is aborting threads. That is done by calling the Abort method of a Thread, which then throws the exception in the thread in order to abort it.
So, are you aborting any thread?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|