We help IT Professionals succeed at work.

Type Conversion Failure on Import from CSV

Davisro
Davisro asked
on
463 Views
Last Modified: 2018-08-24
When importing a CSV file into Access, I received a type conversion error on a number field with 10digits. Access assigned Long Integer to the field but the data did not import. I read here
https://social.technet.microsoft.com/Forums/ie/en-US/ee617aa1-4369-4fb5-82c3-30f481098ce4/access-import-text-file-fails-with-type-conversion-failure?forum=officeitproprevious
that going to the Advanced tab and changing the Code Page from OEM United States to Western European (Windows) would solve the problem and it did. Does anyone understand why?
Comment
Watch Question

Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
At a guess, it changes the way the Wizard identifies the field type.

 Access makes an educated guess as to the field type based on a sampling of the first few rows.  Sometimes it guess wrong.   A common one is on US postal codes, which are 5 digits.  But the US also has zip + 4, so some data will look like this:

12345-6789

 with a dash, meaning you need to import it as a text field.   You also loose a leading zero if it imports it as a number.

 What and why the code page adjustment triggers a change though I have no idea.

  The real fix of course is to adjust the field types.

Jim.
DavisroBudget Analyst

Author

Commented:
Hi Jim. Sure, but the field type seems correct. The 10 digit numbers in Excel are formatted as General. When I pasted them into notepad (multiple excel files totaling 600k records), and then imported the file, Access assigned Long Integer to the field which seemed appropriate, yet, the data then failed to import
Fabrice LambertConsulting
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi,

Within the Import wizard, you can define the data type for each column.
Choose either Double, or Text data type (whatever fit your needs).
Fabrice LambertConsulting
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
but the field type seems correct. The 10 digit numbers in Excel are formatted as General.
Beware that Excel and Access don't handle data type the same way. Access is less tolerant.
DavisroBudget Analyst

Author

Commented:
Fabrice, Alright...so what would be the appropriate data type for a 10 digit number? I'm sure text would work but I don't understand why Long Integer doesn't work
Fabrice LambertConsulting
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Long Integer data types are 32 bits and range from -2147483648 to 2147483647, so not all 10 digits numbers will fit in.

If you need to keep a numeric value, Double type, else Text type.
Chief Technology Officer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Mark EdwardsChief Technology Officer
CERTIFIED EXPERT

Commented:
O.k.  sorry, you don't NEED to set up an import specification for CSV, but it avoids/fixes these kinds of issues.
DavisroBudget Analyst

Author

Commented:
Of course. So Double or Decimal would work. Thanks for pointing this out.
Mark EdwardsChief Technology Officer
CERTIFIED EXPERT

Commented:
Also, if you use VBA to Import .CSV with the TransferText function, you'll need an import specification for that....

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.