Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

20 digit numbers imported via CSV - converted to scientific notation in Excel -

Posted on 2014-01-31
6
Medium Priority
?
1,426 Views
Last Modified: 2014-01-31
hi Folks
Hope you are well.
Got a scenario :-)
Person has very large numbers to download from CSV file (18 plus digits).
When they get to Excel, they are converted to scientific notation...then when the user wants to convert them back to CSV and upload to original programme (as values), they run into problems. So my question is this..
Is there a way to retain the numbers' multiple digits (I know you could do that via Text Wizard and bring in as text) to be suitable for uploading back to original programme.

Thank you as always.
0
Comment
Question by:agwalsh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 664 total points
ID: 39823401
Excel will only retain 15 significant digits. The only workaround is to change the extension to .txt and open the file using the text import wizard, specifying those fields as Text. Or do the same thing using VBA.

Here is the VBA option by taylourmackay:
Public Sub ReadCSV(strFile As String)
    Application.ScreenUpdating = False
    Dim oFSO As New FileSystemObject, oFS As TextStream
    Dim strLine As String, aLine As Variant, nRow As Long, nColumn As Long
    
    nRow = 1
    nColumn = 1
   
    Set oFS = oFSO.OpenTextFile(strFile)
    Do Until oFS.AtEndOfStream
        strLine = oFS.ReadLine
        aLine = Split(strLine, ",")
        With Range(Cells(nRow, nColumn), Cells(nRow, nColumn + UBound(aLine)))
            .NumberFormat = "@"
            .Value = aLine
        End With
        nRow = nRow + 1
    Loop
    oFS.Close
    Application.ScreenUpdating = True
End Sub

Public Sub SaveCSV(ByVal strFile As String)
    Dim oFSO As New FileSystemObject, oFS As TextStream
    Set oFS = oFSO.OpenTextFile(strFile, ForWriting, True)
   
    Dim i As Long, lastRow As Long, lastColumn As Long, strLine As String, aTemp As Variant
    lastRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1
    lastColumn = ActiveSheet.UsedRange.Columns.Count + ActiveSheet.UsedRange.Column - 1
    For i = 1 To lastRow
        aTemp = Application.WorksheetFunction.Transpose(Application.WorksheetFunction.Transpose(Range(Cells(i, 1), Cells(i, lastColumn))))
        strLine = Join(aTemp, ",")
        oFS.WriteLine strLine
    Next i
    oFS.Close
End Sub

Open in new window

0
 
LVL 3

Assisted Solution

by:ola_erik
ola_erik earned 1336 total points
ID: 39823404
Nah u have to use text:

As with other spreadsheets, Microsoft Excel works only to limited accuracy because it retains only a certain number of figures to describe numbers (it has limited precision). Excel nominally works with 8-byte numbers by default, a modified 1985 version of the IEEE 754 specification[1] (Besides numbers, Excel uses a few other data types.[2]) Although Excel can display 30 decimal points, its precision for a specified number is confined to 15 significant figures, and calculations may have an accuracy that is even less due to three issues: round off,[3] truncation, and binary storage.

http://en.wikipedia.org/wiki/Numeric_precision_in_Microsoft_Excel
0
 

Author Comment

by:agwalsh
ID: 39823446
These figures would be 18 digits (not 18 decimal places..) ...does that make a difference (I don't think so based on what you have said.. :-)
0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 3

Accepted Solution

by:
ola_erik earned 1336 total points
ID: 39823466
disregard the decimal points.
excel keeps track of 15 digits, u have 18
u need to use text
0
 

Author Comment

by:agwalsh
ID: 39823714
Not what I hoped to hear but at least I have an answer :-)
0
 

Author Closing Comment

by:agwalsh
ID: 39823716
Thank you :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question