Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   need a help (http://www.go4expert.com/forums/need-a-help-t5985/)

dineshsachdeva 22Aug2007 20:16

need a help
 
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:

shabbir 22Aug2007 21:16

Re: need a help
 
Read a line using the InputFileStream and split the string based on the spaces and you have the row as you want to.

dineshsachdeva 22Aug2007 21:21

Re: need a help
 
hi , thanks for replying , but in the rows there is not equal spaces in the columns...

shabbir 22Aug2007 21:45

Re: need a help
 
Quote:

Originally Posted by dineshsachdeva
hi , thanks for replying , but in the rows there is not equal spaces in the columns...

When you split against the spaces you will get some blank variables and you can always trim and check for null or empty.

dineshsachdeva 22Aug2007 21:52

Re: need a help
 
we need a result like this

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:


if we trim the blank spaces or check for null condition is there then how we can achieve the second enter and the third entry in the database

rhaazy 23Aug2007 00:31

Re: need a help
 
tell whoever is giving you that garbage for input to come up with something more creative...

rhaazy 23Aug2007 00:34

Re: need a help
 
Read the whole document in one byte at a time, checking to see if it is whitespace or a character.
If you have a character, start adding what will be a word into an array, keep adding characters until the character to be added is a whitespace... Do this for the whole thing.
Cross reference your arrays to match up the values. you know the first 4 array members will be, and what the 4 next array members will be, so you will have two arrays, one for the first line, one for the second, then repeat for each additional set of information.


All times are GMT +5.5. The time now is 09:51.