Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Are There Any CSV File Field Column Mapper Tools For MS Access CSV File importing

Posted on 2016-11-13
12
Medium Priority
?
106 Views
Last Modified: 2016-11-13
I was wanting to import CSV Files into Access but they have different names and are arranged in different orders. Are there any tools for this or can this be done in Access by VBA or something else? I will need to append these CSV New Records to my existing Access Tables.
Thanks!
0
Comment
Question by:Dustin Stanley
  • 5
  • 4
  • 3
12 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41885403
the easier way is to import the CSV file (using import specification) to a temp table, then use an append query to add the records to the existing table.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 41885407
the other way is to create a table to map (mapping table) the CSV column names to the existing table field names.
use a User define function to import the csv file and determine which csv column name corresponds to the table field using the mapping table.
0
 

Author Comment

by:Dustin Stanley
ID: 41885410
Would I delete the table afterwards or could I use that same table over and over? I suppose I could set up long term temp table with the same field names as from the CSV file that I am importing from. I will be using this table daily but I want the information to be truly stored in My Database Table not a Temp Table.

How would I completely clear out this Tempt Table besides fieldnames after I run the Append Query to append to My Table from the Temp Table?

mapping table

This would store the information in the Tempt Table and not My table Correct? If so I don't think that will work long term for me.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 23

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 1000 total points
ID: 41885415
adding on to what Rey said

to make sure all the data comes in, you may want to set the data type for each column to be text. Access will convert to numbers and dates when you append them

just saw your new post.  You can use the same table (that way you won't have to set the fields to text, the table definition can do that).  Be sure to compact/repair database when you open again, just after you back it up, in case something happens during that process. Creating records and deleting them will bloat the database.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 41885418
another way is to Link to the CSV file.
this can also be done using vba codes after selecting the CSV file

docmd.TransferText acLinkFixed, "specificationName","TableName","C:\myFolder\myCSV.csv",true

or
docmd.TransferText acLinkDelim, "specificationName","TableName","C:\myFolder\myCSV.csv",true


--- to clear the temp table, just create delete query

delete * from tempTable
0
 

Author Comment

by:Dustin Stanley
ID: 41885420
to make sure all the data comes in, you may want to set the data type for each column to be text.

So your saying make the tempt table fields all text. Then when I Append them to My Table access will automatically convert them to the correct data type..Correct?
0
 

Author Comment

by:Dustin Stanley
ID: 41885429
another way is to Link to the CSV file.

Ok so I can directly link with this file...These CSV files will be exported from a location daily and placed on to my PC. The daily CSV file will have only new updated info. Nothing from the day before (Yesterday).

Would I Delete Yesterday's file (or rename it) and then make sure the new day (Today's) file has the same name as Yesterdays File?
0
 

Author Comment

by:Dustin Stanley
ID: 41885432
By the way there should NOT be any relationships to this Temp Table Correct?
0
 
LVL 23

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 1000 total points
ID: 41885435
> "make the tempt table fields all text"

yes. That is what I do. sometimes the expected data type is not actually what is in a field and when that happens, the whole record won't come in.  By setting to text, you can ensure everything comes in. Then, after appending to where it needs to go, you should :

1. filter records for the new ones
2. sort by the number and date columns, one at a time, and make sure there aren't blanks.  If there are, you can look at the temporary import table.

When importing, it is good to start the tablename with "import" so it is easy to find -- and later delete if you want.

> "NOT be any relationships to this Temp Table Correct?"
yes

Rey also mentioned: "another way is to Link to the CSV file" -- if you are doing this everyday, this might be good to consider doing instead of actually importing.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 41885508
-first time when you create a link to the CSV file, you can specify the name for the Linked CSV.
-second time you make a link to the CSV file and use the same name, it will overwrite the first link you created.

you do the linking by
external data > text file > browse and locate the csv file > select link to the data source ...  click OK and follow the wizard
0
 

Author Closing Comment

by:Dustin Stanley
ID: 41885657
Thank You!
0
 
LVL 23
ID: 41885699
you're welcome ~ happy to help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

926 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