need a help

dineshsachdeva's Avatar, Join Date: Aug 2007
Newbie Member
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:
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Read a line using the InputFileStream and split the string based on the spaces and you have the row as you want to.
0
dineshsachdeva's Avatar, Join Date: Aug 2007
Newbie Member
hi , thanks for replying , but in the rows there is not equal spaces in the columns...
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
0
dineshsachdeva's Avatar, Join Date: Aug 2007
Newbie Member
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
0
rhaazy's Avatar, Join Date: Jul 2007
Go4Expert Member
tell whoever is giving you that garbage for input to come up with something more creative...
0
rhaazy's Avatar, Join Date: Jul 2007
Go4Expert Member
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.