|
It's funny... every time you post on asking how to do something, you end up figuring it out for yourself a not too long after..
I figured I would have to use a custom TypeConverter, based on some article i finally found here on serialization.
|
|
|
|
|
SteelixB wrote: It's funny... every time you post on asking how to do something, you end up figuring it out for yourself a not too long after..
I've done that before myself. Posting generally means a casual google didn't find anything, depending on priority I might keep diging even after I post.
|
|
|
|
|
Hi All,
I am having trouble with CSV files
Everything works fine if the csv is formatted as bellow example
header ---> one, two, three, four
Data 1------> ab, bc, de, fg
Data 2------> cb, cc, ce, cg
However sometimes i get a file that has a row spilt over two lines as bellow example
header ---> one, two, three, four
Data 1------> ab, bc, d
Data 1------> e, fg
Data 2------> cb, cc, ce, cg
Does anyone know how to search through a csv file and remove any occurrences of this split line problem ???
I would be most grateful for any help
Thanks
John
|
|
|
|
|
The problem is that you are reading the file the wrong way. The records are separated by line breaks, but fields in a record may also contain line breaks. Therefore you should read the file as a stream instead of line by line.
Normally, a field containing line breaks will be enclosed in quotes:
one, two, three, four<br />
ab, bc, "d<br />
e", fg<br />
cb, cc, ce, cg
If you just keep track of whether you are inside a quote or not, the line breaks are no problem. If you are inside the quote, a line break is just data, not a record separator.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
Thanks for the quick response !!!
I have never seen " " around the line break.
Any more info on how to read the file as a stream would be fab !!!
I am kinda new to all this
Thanks again !!!
John
|
|
|
|
|
Sadly there exists no proper standard or specification for CSV files.
Where does the CSV files come from? If possible, try to get a specification of the format used.
If the fields containing line breaks are not quoted, you will have a tricky task to separate the line breaks in the fields from the record separating line breaks.
It's possible as long as there are no line breaks in the last field of the records. If there are, it might be impossible to read the file. Look at this example:
1, 2, 3<br />
aa, bb, cc<br />
xx<br />
aa, bb, cc
Does the "xx" part belong to the last field of the first line, or the first field of the last line? It's impossible to tell.
---
b { font-weight: normal; }
|
|
|
|
|
Umm i see your point
the last field is an ID Number so it is unlikely that this would ever have any form of line break.
The ones I have looked at seem to contain the break at random points in the line. almost as though someone has just randomly hit the enter key whilst scrolling the csv.
How would you recommend solving this prob ? even if it is not fully reliable.
How does this stream line thing work ??
I really don’t know where to start
Thanks
John
|
|
|
|
|
I am trying to monitor a thread I created in my application. Specifically, I need to go process messages when the thread exits (either gracefully or it has been killed). Is there anyway in Windows CE that I can do this?
|
|
|
|
|
Hai all,
I want to show a UserControl instead of the default dropdown list when I click on the ComboBox dropdown arrow. Is there a way to catch this message and show my control instead of this?
Thanks in advance.
VPMahank
|
|
|
|
|
|
Draders23,
Thanks so much for the link . I tried overriding the WndProc for the control and show my own customcontrol instead of regular dropdown.
Thanks,
VPMahank
|
|
|
|
|
Hey
First I would like to say that this is a VERY GOOD site! Jesus, I can find anything around here. You always have the solutiion for everyone. hehe. Good job
But I didn' come here for that (only for that).
I'm working in a place where they want me to do a calendar to introduce events... I used the Calendar WebControl from .NET platform but there's a problem. The boss wants me to make a displayable calendar... What he means is that the user can view the dates in various formats...
Per day: only displays the hours
Per week: displays the dates of that week
Per month: don't have to say!
Per year: Display all month at once
I want to know if there's I way to do this using the Calendar Web Control. If not how can I do this?!
I know this is stretchy but I really need this done... In C# if possible!
Many thanks and have a nice work everybody
andrecarrilho
|
|
|
|
|
I have a program that has 5 worker threads constantly monitoring and changing a static DataTable. The DataTable is in a DataSet and is bound to a main DataGrid in this manner.
MainGrid.SetDataBinding(DSet,DBox.TableName);
The binding works fine and will add and change data with no problem. The problem comes when one of the worker threads removes a row from the DataTable. About 50% of the time I get an IndexOutOfRangeException thrown in the OnPaint of the main DataGrid. Each time there is a different row that caused the problem. ie "No Index at Row 5" This is how I am removing the rows.
if(MasterLock.Available(-1,10))<br />
{<br />
try<br />
{<br />
this.Rows.Remove(row);<br />
this.AcceptChanges();<br />
}<br />
catch(Exception _i)<br />
{<br />
_i.ToString();<br />
}<br />
finally<br />
{<br />
MasterLock.Release();<br />
}<br />
}
Any ideas?
|
|
|
|
|
Hi,
The problem could be that you are accessing a control from a worker thread. .Net 2.0 throws an exeption if you try this, but I guess you are using .Net 1.1 which allows the call but fails randomly.
You can test this my using this.InvokeRequired . If this is the case, then wrap your control access in an this.Invoke or this.BeginInvoke call.
----------------------------
Be excellent to each other
|
|
|
|
|
Hello,
How can I write the DataSet Contents into a CSV file?
Thank you.
|
|
|
|
|
Assuming there is only one DataTable in the DataSet then you can just iterate through the rows of the DataTable, then iterate through each of the columns writing the information to a file. Each column iteration loop writes a comma after the value, except the last iteration. Each iteration of the rows writes a newline after writing out the columns, except for the last row.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Hi,
I'm just starting out with DirectX and am running into some trouble (I've been piecing parts of examples together). I have a couple rectangles that yaw, roll, and pitch as they zoom in. When they come back to face the front (so it only looks 2d), I stop the movement and add a couple triangles. Up to here it works just fine. Now I'd like to add a bitmap under the rectangles but run into trouble. I have:
private override OnPaint()<br />
{
some twirling of boxes for a few seconds that become still with this line:
DrawBox(0.0f, 0.0f, 0.0f, -0.45f, 0.8f, 9.5f); (code for DrawBox below)
then I add a couple triangles...
CustomVertex.TransformedColored[] vert = new CustomVertex.TransformedColored[3];
... describe the vert ...
device.VertexFormat = CustomVertex.TransformedColored.Format;<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vert);
Things work fine up to here. At this point I'd like to add my bitmap (Texture tex). I change the VertexFormat and call DrawBitmapBox (this is how one example added a texture to a box):
device.VertexFormat = CustomVertex.PositionTextured.Format;<br />
device.SetStreamSource(0, vb, 0); vb is the VertexBuffer - also below
DrawBitmapBox(0.0f, 0.0f, 0.0f, 2.0f, 2.0f, 9.5f, tex); (code also below)
}
Instead of drawing the bitmap image, the original rectangles themselves kind of blink (not at any contant rate), while the triangles just sit there like everything's ok. I know I'm probably making some obvious mistake(s), but any help in getting this bitmap up would be great!!!
Mel
DrawBox
private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z)<br />
{<br />
angle += 0.01f;<br />
device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);<br />
Material boxMaterial = new Material();<br />
device.Lights[0].Type = LightType.Directional;<br />
device.Lights[0].Diffuse = Color.Red;<br />
device.Lights[0].Direction = new Vector3(0,-1,-1);<br />
device.Lights[0].Commit();<br />
device.Lights[0].Enabled = true;<br />
boxMaterial.Diffuse = Color.White;<br />
device.Material = boxMaterial;<br />
mesh.DrawSubset(0);<br />
}
DrawBitmapBox
<br />
private void DrawBitmapBox(float yaw, float pitch, float roll, float x, float y, float z, Texture t)<br />
{<br />
angle += 0.00f;<br />
device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);<br />
device.SetTexture(0, t);<br />
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 6);<br />
}
VertexBuffer stuff
under InitializeGraphics:
vb = new VertexBuffer(typeof(CustomVertex.PositionTextured), 6, device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);<br />
vb.Created += new EventHandler(this.OnVertexBufferCreate);<br />
OnVertexBufferCreate(vb, null);
OnVertexBufferCreate:
private void OnVertexBufferCreate(object sender, EventArgs e)<br />
{<br />
VertexBuffer buffer = (VertexBuffer)sender;<br />
<br />
CustomVertex.PositionTextured[] v = new CustomVertex.PositionTextured[6];<br />
v[i] = ...<br />
buffer.SetData(v, 0, LockFlags.None);<br />
}
|
|
|
|
|
Are the dimensions of your bitmap powers of 2? If I recall correctly they have to be powers of two to work as textures.
I hope this helps.
Deus caritas est
|
|
|
|
|
Hi,
I am making a program and in the menu bar I did a menu bar item called About. Now I would like that when I open the About form the main form will be disabled. I did that and it worked. But now how should I make it enabled again after I close the About form?
Thanks a lot
|
|
|
|
|
Hi,
You want to display your about form as a modal dialog:
private void menuItemHelpAbout_Click(object sender, System.EventArgs e)
{
FormAbout dlg = new FormAbout();
dlg.ShowDialog();
} This will "disable" your main form while the about box is shown.
----------------------------
Be excellent to each other
|
|
|
|
|
I don't think you understood me. I disabled the form but I would like that when I close the About form, the main form will be enabled again. How can I do that?
thanks
|
|
|
|
|
hi
I use an aaplication which write to a log file every ~ 1sec.
i need to build an appliaction that will display the contents of this and updtae the display as it works.
i tried using StreamReader but was unsuccessful i get sharing violation when both apps trying to access the file.
please help.
Have a nice Day
|
|
|
|
|
i think you need to use different threads for reading and writing, so as not to try to do both simultaneously. You will probably need to use lock keyword, as well as Monitor.Pulse and Monitor.Wait methods.
Try reading the help on these and have a nice day too.
there are no facts, only interpretations
|
|
|
|
|
I am using the Win32 GetClassInfoEx to get the small icon of a window from another application. GetClassInfoEx returns a IntPtr to the 16x16 small icon.
How do i put the image located at this IntPtr into a Bitmap so that i can use it in NET? There does not seem to be a function in NET that converts an image pointer into an image.
I have hit a brick wall. Can someone nudge me in the right direction about what to do?
|
|
|
|
|
Try:
Bitmap bitmap = Bitmap.FromHicon( hicon );
----------------------------
Be excellent to each other
|
|
|
|
|