+ Reply to Thread
Results 1 to 8 of 8

Export Excel data to txt file in special format

  1. #1
    Registered User
    Join Date
    02-05-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    5

    Export Excel data to txt file in special format

    Hello,

    I want to export excel data to txt file in certain format. I have excel file with data in certain columns and I only want to select certain columns. Here is what data looks like in excel file. Also I am attaching excel file just to be more clear.

    _A B C D E F G H I
    1 b1 c1 e1 f1 h1
    2 b2 c2 e2 f2 h2
    3 b3 c3 e3 f3 h3
    4
    5 b4 c4 e4 f4 h4
    6 b5 c5 e5 f5 h5

    Here Columns A, D G, and I are empty. Also row 4 is empty
    I want to generate a text file with columns C, E, H only ignoring any blank row or cell. So that the format of the txt file would be something like following.
    data_e1(c1,e1,h1)
    data_e2(c2,e2,h2)
    data_e3(c3,e3,h3)
    data_e4(c4,e4,h4)
    data_e5(c5,e5,h5)

    Note that I'm appending "data_e#" depending on the data from column E.

    Any help would be greatly appreciated,

    Thanks

    .
    Attached Files Attached Files
    Last edited by tan123; 02-05-2010 at 12:25 PM.

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Export Excel data to txt file in special format

    welcome to the boards!

    how about the attached? I assumed what you meant by a blank row was that b,c,e,f, and h were blank. the file name can be anything of your choosing

    test123.xls
    Bob
    Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.

  3. #3
    Registered User
    Join Date
    02-05-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Export Excel data to txt file in special format

    Thanks a lot for the reply. This is great. I really appreciate all your help.
    I need one more favor. Lets say some of the cell in the row are empty as shown below or in the file attached.

    _A B C D E F G H I
    1 b1 c1 e1 f1 h1
    2 b2 __ e2 f2 __
    3 b3 c3 e3 f3 h3
    4
    5 b4 c4 __ f4 h4
    6 b5 c5 e5 f5 __

    So, as you can see above cell c2, h2, e4, and h5 are empty. "__" represents an empty cell. Now, I want the txt file as shown below.

    data_e1(c1,e1,h1)
    data_e2(e2)
    data_e3(c3,e3,h3)
    data_e4(c4,h4)
    data_e5(c5,e5)

    So it will ignore an empty cell and the comma associated with it.

    Also, is it possible to check column E or any column for any typo in it. For example, lets say columns E can only contain (int, boolean, byte, bit). So if somebody type "ing" instead of "int" or "baolaaan" instead of "boolean" it should issue an error saying that error found at row12 or something.

    Thank again
    Attached Files Attached Files
    Last edited by tan123; 02-05-2010 at 03:59 PM.

  4. #4
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Export Excel data to txt file in special format

    This one is close to what you say is the answer except that e4 is blank, so data_e4(c4,h4) is not generated. Should column "F" be used?test123.xls

  5. #5
    Registered User
    Join Date
    02-05-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Export Excel data to txt file in special format

    There is no need to include column F.

    It outputs,
    data_e1(c1,e1,h1)
    data_e2(e2)
    data_e3(c3,e3,h3)
    data_e5(c5,e5)

    It missing "data_e4(c4,h4)"
    I want to check for blank row also. So if blank row do nothing.
    Also, is it possible to check column E or any column for any typo in it. For example, lets say columns E can only contain (int, boolean, byte, bit). So if somebody type "ing" instead of "int" or "baolaaan" instead of "boolean" it should issue an error saying that error found at row12 or something.
    Last edited by tan123; 02-05-2010 at 04:25 PM.

  6. #6
    Registered User
    Join Date
    02-05-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Export Excel data to txt file in special format

    Sorry my bad. It missing e4 so obviously it won't output that row.

    So my only concern is to check for any typos in column E.

  7. #7
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Export Excel data to txt file in special format

    Yes, "data_e4(c4,h4)" because there is no e4.
    Here are the latest changes based on your example. When an error is detected the cell with the error is selected.test123.xls

  8. #8
    Registered User
    Join Date
    02-05-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Export Excel data to txt file in special format

    Worked Perfectly. You're great. I greatly appreciate all your help. Once again thanks a lot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1