+ Reply to Thread
Results 1 to 13 of 13

Export to Excel Converts String Values to Numbers

  1. #1
    Forum Contributor Mvaldesi's Avatar
    Join Date
    01-21-2011
    Location
    Plano, TX
    MS-Off Ver
    MS365 (PC) v.2108
    Posts
    259

    Export to Excel Converts String Values to Numbers

    Good afternoon, Gurus and Experts,

    I’m not sure if this is the correct section of the forum, but it feels like a “general” question. I’m working with a “big data” prep platform called Datameer; within it, I am able to see/specify/change datatypes. I’ve got a bunch of 20-digit carton numbers, each starting with 4 leading zeros (“0000”,) and Datameer has designated them a “string” format, which is what I want. However, when I go to export from Datameer to Excel (into a *.csv,) Excel converts the carton numbers from the string format to “General,” dropping the leading zeros and listing them in scientific notation. This wouldn’t be a problem as I could normally change the formatting to number with zero decimal places to break the number back out to its true form and add the leading zeros manually, but when I do this, it changes all of the last digits of the numbers to “0.” My short term solution is to add a leading alpha (“X”) to the carton numbers to ensure they’re stay as strings, then find/replace the “X” with an apostrophe, effectively converting the full 20-digit numbers to strings, but I’d like to know why this is happening, and is there a way to prevent Excel from doing it?

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Export to Excel Converts String Values to Numbers

    =TEXT(A2,"00000000000000000000")

    This will add the leading 0000 to your carton ID even if it shows scientific notation. There are 20 0's in that formula above.

  3. #3
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Export to Excel Converts String Values to Numbers

    You could also use this formula

    ="0000"&A2

  4. #4
    Forum Contributor Mvaldesi's Avatar
    Join Date
    01-21-2011
    Location
    Plano, TX
    MS-Off Ver
    MS365 (PC) v.2108
    Posts
    259

    Re: Export to Excel Converts String Values to Numbers

    Thank you for your response, but adding the leading zeros isn't my problem. The issue occurs when I export the 20-digit carton numbers in a string format and Excel changes them to numbers ("General" format,) and converting them from the scientific notation back to a legible format, I lose the trailing digit. Example:

    - In Datameer, I've got "00007644150013427176" as a String
    - It exports to Excel as "7.64415E+15"
    - I convert that to a number with zero decimal places, and I get "7644150013427170" where I've lost the leading zeros (which I know how to fix,) but the last digit is now "0," which I CAN"T fix.

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

    Re: Export to Excel Converts String Values to Numbers

    Exactly how are you importing the data into Excel? Excel will always try to import data as "helpfully" as it can -- which means that if Excel sees something in the import that it can interpret as a number, it will (by default) try to convert it to a number. You will need to do something during the import step to try to prevent or override this default behavior. For example, if you are importing from a text file, there is a step in the text import wizard where you can tell Excel to treat a column as text to override its default behavior of converting anything that looks like a number to a number. How are you exporting from Datameer/importing into Excel -- and what options do you have during that process to override Excel's default behavior?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Export to Excel Converts String Values to Numbers

    Rather than opening the csv in excel, you need to import it, via the data tab.
    Then on the 3rd page of the impost wizard, you can select the relevant column & click "Text".
    This should keep the data intact.

  7. #7
    Forum Contributor Mvaldesi's Avatar
    Join Date
    01-21-2011
    Location
    Plano, TX
    MS-Off Ver
    MS365 (PC) v.2108
    Posts
    259

    Re: Export to Excel Converts String Values to Numbers

    Thank you both, MrShorty and Fluff13; I will have to look at what options I have in Datameer; I just had a co-worker telling me it was behavior within Excel (as you suggest, MrShorty,) so I thought the solution would need to be on that end.

    Fluff13, I can't "import" it into Excel because the export doesn't exist until Datameer creates it (the *.csv file.) But perhaps I can export it to a text file, then import it to Excel?

    Seems I have some options/experimenting to do; I'm going to leave the thread unsolved for now, but will close it if one of the solutions you've suggested works out. Thanks!

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

    Re: Export to Excel Converts String Values to Numbers

    I somehow missed that the data was passing through a .csv (comma separate values text) file between Datameer and Excel. Fluff13's suggestion is probably the one you need, just be sure to check the "text" option at the appropriate step in the text import wizard. Another option, if Datameer will allow, is to save as a regular text .txt file. Excel bypasses the text import wizard when opening .csv files, but will bring up the text import wizard when opening .txt files.

  9. #9
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Export to Excel Converts String Values to Numbers

    if datameer creates the .csv file.
    First open the csv file in Notepad or Wordpad. This will reassure you that datameer is indeed exporting the data correctly.
    I believe Fluff was suggesting you open a blank excel then select the Data ribbon. Then select "From Test/Csv" and find your csv file and import it into excel that way using TEXT

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Export to Excel Converts String Values to Numbers

    Quote Originally Posted by dosydos View Post
    I believe Fluff was suggesting you open a blank excel then select the Data ribbon. Then select "From Test/Csv" and find your csv file and import it into excel that way using TEXT
    I was indeed suggesting that, just obviously didn't do a very good job of it

    @Mvaldesi
    Thanks for the Rep.

  11. #11
    Forum Contributor Mvaldesi's Avatar
    Join Date
    01-21-2011
    Location
    Plano, TX
    MS-Off Ver
    MS365 (PC) v.2108
    Posts
    259

    Re: Export to Excel Converts String Values to Numbers

    Thank you all; I figured out how best (if cumbersomely) to do it. Datameer only has three options to export: *.csv, a *.tdsx (a Tableau file type,) or to a *.zip. I had to use the last type, then import from an open session of Excel where, as MrSHorty predicted, I'm able to specify my data types and maintain the integrity of my data. It's a pain, but it works; for all Datameer can do, it really drops the ball in some really basic areas.

    Thanks again; marking the thread solved now!

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Export to Excel Converts String Values to Numbers

    Have you seen what dosydos said in post#9?

  13. #13
    Forum Contributor Mvaldesi's Avatar
    Join Date
    01-21-2011
    Location
    Plano, TX
    MS-Off Ver
    MS365 (PC) v.2108
    Posts
    259

    Re: Export to Excel Converts String Values to Numbers

    Quote Originally Posted by Fluff13 View Post
    I was indeed suggesting that, just obviously didn't do a very good job of it
    Haha! No, since your suggestion was perfectly clear to someone other than me, I think the onus of misunderstanding lies with this dimwit right here! Thanks a ton!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 08-14-2018, 09:28 AM
  2. Import excel to MSSQL converts long numbers to +000
    By whatever61 in forum Excel General
    Replies: 6
    Last Post: 12-14-2017, 05:41 PM
  3. Excel automatically converts numbers to a date
    By rinconmike in forum Excel General
    Replies: 3
    Last Post: 04-15-2014, 02:24 PM
  4. Excel converts csv values without permission or notice
    By 86smopuiM in forum Excel General
    Replies: 2
    Last Post: 11-01-2012, 05:45 PM
  5. Replies: 0
    Last Post: 05-25-2012, 08:52 AM
  6. String converts to date - text doesn't help!
    By KathyC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2006, 10:48 AM
  7. converts numbers to dates
    By jason2444 in forum Excel General
    Replies: 2
    Last Post: 02-10-2006, 06:45 PM

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