need a help

Discussion in 'C#' started by dineshsachdeva, Aug 22, 2007.

  1. dineshsachdeva

    dineshsachdeva New Member

    Joined:
    Aug 22, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    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:
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Read a line using the InputFileStream and split the string based on the spaces and you have the row as you want to.
     
  3. dineshsachdeva

    dineshsachdeva New Member

    Joined:
    Aug 22, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hi , thanks for replying , but in the rows there is not equal spaces in the columns...
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    When you split against the spaces you will get some blank variables and you can always trim and check for null or empty.
     
  5. dineshsachdeva

    dineshsachdeva New Member

    Joined:
    Aug 22, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  6. rhaazy

    rhaazy New Member

    Joined:
    Jul 6, 2007
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
    tell whoever is giving you that garbage for input to come up with something more creative...
     
  7. rhaazy

    rhaazy New Member

    Joined:
    Jul 6, 2007
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice