+ Reply to Thread
Results 1 to 9 of 9

Keeping cell number format when converting from Excel to .CSV

  1. #1
    Registered User
    Join Date
    10-25-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    4

    Keeping cell number format when converting from Excel to .CSV

    I have files that need to be uploaded to our operational software using the .CSV format. When I receive the initial file, it is in excel format and thus needs to be converted. Problem is that some of the cells being uploaded contain characters saved as a "Text" formatted cell and are converted to whatever excel thinks it should be when changing to .CSV.

    For example. A cell could contain 3981-5-19 and with a cell format of "text". When the file is converted to .CSV, the cell now would read 5/19/3981 or 19-May. I need the original formatting to stay when I convert the file, otherwise the item isn't recognize in the .CSV upload to our oeprational software.

    Any help, suggestions, responses, etc. is greatly apprecaited.

    Thanks!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Keeping cell number format when converting from Excel to .CSV

    a cell formatted as text saved as csv keeps its formatting
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    10-25-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Keeping cell number format when converting from Excel to .CSV

    Quote Originally Posted by martindwilson View Post
    a cell formatted as text saved as csv keeps its formatting
    Appreciate the response, but that's not happening in this case. It's the first thing I tried and got the same result each time. Tried several different variations of copying, pasting, saving, etc. and each time, it changed from a TEXT format in excel and defaulted automatically back to GENERAL format after being saved. Same occured when I changed the cell format to TEXT after it had already been converted to .CSV.

    If there is a setting or something I am missing, feel free to point out what that would be, but otherwise, what you claim in your response, is not happening.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Keeping cell number format when converting from Excel to .CSV

    got a sample work book?

  5. #5
    Registered User
    Join Date
    10-25-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Keeping cell number format when converting from Excel to .CSV

    I've attached the xls file I am pulling the data from.
    Attached Files Attached Files

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Keeping cell number format when converting from Excel to .CSV

    here it is saved as csv
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Keeping cell number format when converting from Excel to .CSV

    For example. A cell could contain 3981-5-19 and with a cell format of "text". When the file is converted to .CSV, the cell now would read 5/19/3981 or 19-May.
    If I can nitpick -- exactly how are you determining that the given cell entry is wrong in the CSV file? I

    If I take your file, save as a CSV file, then open the CSV file in a text editor (like wordpad), the file looks exactly like it did in Excel (without the gridlines). If I then open the CSV file back into Excel, that's when Excel tries to convert the text strings it can recognize as dates to dates.

    Your post suggests that these CSV files are not intended to be read by Excel. I would suggest you determine for sure that the problem is occuring when Excel creates the CSV file. The CSV file might be correct, even if Excel can't read the file correctly.

  8. #8
    Registered User
    Join Date
    10-25-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Keeping cell number format when converting from Excel to .CSV

    Quote Originally Posted by MrShorty View Post
    If I can nitpick -- exactly how are you determining that the given cell entry is wrong in the CSV file? I

    If I take your file, save as a CSV file, then open the CSV file in a text editor (like wordpad), the file looks exactly like it did in Excel (without the gridlines). If I then open the CSV file back into Excel, that's when Excel tries to convert the text strings it can recognize as dates to dates.
    Your post suggests that these CSV files are not intended to be read by Excel. I would suggest you determine for sure that the problem is occuring when Excel creates the CSV file. The CSV file might be correct, even if Excel can't read the file correctly.
    Nailed it. When reading the file in wordpad, it looks exactly as it's meant to. When trying to read it in EXCEL, that's when the problem occus. You are correct that the file is accurate, the program reading it is skewing it when viewed in EXCEL.

    My problem is that the upload I need only recognizes the EXCEL .CSV when deducing the columns - when I use the .txt format, it brings up everything in a single column.

    If there is a way to correct the formatting when EXCEL read the file so that the cell format doesn't convert, then that's what I need to. If that's not possible, then it's an issue with the software I am uploading to and I need to get it corrected through that route.

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Keeping cell number format when converting from Excel to .CSV

    If there is a way to correct the formatting when EXCEL read the file so that the cell format doesn't convert, then that's what I need to. If that's not possible, then it's an issue with the software I am uploading to and I need to get it corrected through that route.
    I think the latter option is best. .CSV files are really no different from any other ASCII text file (.txt) -- they can't really store formatting information. Any "changes" to the .CSV file (like interpreting xxxx-x-x as a date rather than text) are done at the whim of the programming opening/reading the .CSV file. In the end, the best solution to your problem (if there really is a problem) will be determined by understanding how the target program reads the data in the file.

+ 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