Solved

Importing CSV Without Losing Decimals

Posted on 2014-10-07
3
505 Views
Last Modified: 2014-10-07
I am importing some large CSV files to Access. I've tried linking to the tables and using append queries, straight imports, and just about every field definition I can think of, but there are some columns that have decimals in them and I lose them on the finished product.

The majority of the values in these columns are "1" - so when Access examines the file for import, it interprets it as a long integer. I've changed the destination table field to Double to catch the decimal values, but it still suppresses everything after the decimal. I even tried text as a field type.

Since the file I am importing is a .csv, I don't get very extensive options when importing. But I have to get this data into my database WITH the decimal values.

Any help appreciated.
0
Comment
Question by:Buck_Beasom
3 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40365985
Edit the data - Create a dummy first row, which has a decimal value (e.g. 1.23), and then delete that dummy row.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40366059
you need to create import specification first.

 To create the Import Specification
  1) Click on external data> text file which then opens another window called "Get external data - Text file"
  2) Use radio button to select "Import the source data into a new table in the current database"
  3) specify the source of the file using the browse procedure then click OK
  4) Choose radio button to select delimited format and then click next
  5) this window allows you to choose delimiter and text qualifier and if first row contains names - click next
  6) This window allows you to type the name of the field in the Field Name column, choose data type, and if you want field indexed - also can choose to skip field - then click next
  7) This window allows you to add primary key or designate field as such - click next
  8) Click on ADVANCED button
  9. in the import specification window
  type the name of the field in the Field Name column
  (here you can use the field names of the destination table, specify data type,
  check the box Skip if you do not want to import the column)
  10 click save as, give the specification a name <-- this is the specification name that you will use in the command line below


DoCmd.TransferText acImportDelim, "ImportSpecificationName", "TableName", "C:\folderName\myText.csv" , True



.
0
 

Author Closing Comment

by:Buck_Beasom
ID: 40366675
Perfect. Thanks!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…

831 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