| | |
Need a help
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 1
Reputation:
Solved Threads: 0
hi!
i'm new to the C#. net and need a help for my application, thanks in advance,problem is i have an application which has to read the data which is like this
-------------------------(white spaces which is in the file)
--------- abc ---------- d----------- efd----------- de
xxx----- 25.80---------12.10--------180000.0--------11111
yyyyyyyy---------------709.-----------.03-------------------
zz-------------------------------------1426.-------------------------
and has to make an entry in the database in a table as
table structure is name, abc , d, efd, de
first entry should be
name: xxx
abc:25.80
d:12.10
efd:180000.0
de:11111
second entry should be
name: yyyyyyyy
abc:
d:709.
efd:.03
de:
second entry should be
name: zz
abc:
d:
efd:.1426.
de:
i'm new to the C#. net and need a help for my application, thanks in advance,problem is i have an application which has to read the data which is like this
-------------------------(white spaces which is in the file)
--------- abc ---------- d----------- efd----------- de
xxx----- 25.80---------12.10--------180000.0--------11111
yyyyyyyy---------------709.-----------.03-------------------
zz-------------------------------------1426.-------------------------
and has to make an entry in the database in a table as
table structure is name, abc , d, efd, de
first entry should be
name: xxx
abc:25.80
d:12.10
efd:180000.0
de:11111
second entry should be
name: yyyyyyyy
abc:
d:709.
efd:.03
de:
second entry should be
name: zz
abc:
d:
efd:.1426.
de:
Is the spacing consistent in the file? Like do each of the values always start at the same column?
If yes, you can use the starting column index for each item to extract the values. Read the first x characters from index y of the row. Trim the result and if it's an empty string, the field you put into the database is null. If the values don't start on the same column, you have a problem because there might not be a way to know which fields are null and which fields aren't if there aren't four values for each name...
C# Syntax (Toggle Plain Text)
abc d efd de xxx 25.80 12.10 180000.0 11111 yyyyyyyy 709. .03 zz 1426.
Last edited by Hamrick; Aug 22nd, 2007 at 12:11 pm.
The truth does not change according to our ability to stomach it.
•
•
•
•
This looks like a recipe for disaster. You need to think of a better(more unique) way to identify each column. Counting white space just ain't gonna cut it.

In fact, this is exactly what I did to parse and reformat some reports for a local wholesaler. The column widths were always the same and the company is still using the report filters to this day without any problems. If dineshsachdeva's file isn't fixed width, this won't work, but neither will anything else that I can think of because there's no way to tell if there's an empty field in between one field and the next.
The truth does not change according to our ability to stomach it.
> It's not counting whitespace, it's relying on a fixed width column format.
Nah, that is just stupid. And he never said he's using fixed width column if you reread the original thread so you are making assumptions.
There are much easier ways to do this, (much more flexible too) I'm afraid.
Nah, that is just stupid. And he never said he's using fixed width column if you reread the original thread so you are making assumptions.
There are much easier ways to do this, (much more flexible too) I'm afraid.
Last edited by iamthwee; Aug 22nd, 2007 at 4:37 pm.
•
•
•
•
Nah, that is just stupid.
•
•
•
•
And he never said he's using fixed width column if you reread the original thread so you are making assumptions.
•
•
•
•
There are much easier ways to do this, (much more flexible too) I'm afraid.
The truth does not change according to our ability to stomach it.
![]() |
Other Threads in the C# Forum
- Previous Thread: Select Random Number from Access Table Using C#
- Next Thread: MS SQL server 2005 Express Edition
| Thread Tools | Search this Thread |
.net access ado.net algorithm api array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime decryption degrees development drag draganddrop drawing encryption enum event excel file form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label list listbox mandelbrot marshalbyrefobject math mouseclick mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform polynomial post programming radians regex remote remoting richtextbox serialization server sleep socket sql statistics stream string study table text textbox thread time timer update usb usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml






