Avatar of Davisro
Davisro
Flag for United States of America asked on

Type Conversion Failure on Import from CSV

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?
Microsoft Access

Avatar of undefined
Last Comment
Mark Edwards

8/22/2022 - Mon
Jim Dettman (EE MVE)

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.
Davisro

ASKER
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 Lambert

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).
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Fabrice Lambert

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.
Davisro

ASKER
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 Lambert

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Mark Edwards

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mark Edwards

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

ASKER
Of course. So Double or Decimal would work. Thanks for pointing this out.
Mark Edwards

Also, if you use VBA to Import .CSV with the TransferText function, you'll need an import specification for that....
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck