473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to import data in Text format in MS Access?

Hi Experts..

I am having issues on importing full data into the database, because of failing in converting the data type.

Example as below Screenshot.

Currently I am using below codes

Expand|Select|Wrap|Line Numbers
  1. Sub ImportData()
  2. DoCmd.RunSQL "SELECT vTbl.* 
  3.               INTO NewTable 
  4.               FROM (SELECT vCSV.* 
  5.                     FROM [Text;
  6.                           FMT=Delimited;
  7.                           HDR=YES;
  8.                           IMEX=2;
  9.                           CharacterSet=437;
  10.                           DATABASE=C:\Input].[Sales.csv] As vCSV) As vTbl"
  11. End Sub
  12.  
Is there any work around for this?

thanks for your help in advance!

Attached Images
File Type: jpg Ill.jpg (10.8 KB, 634 views)
Aug 31 '18 #1

✓ answered by zmbd

Raymond,
Please keep in mind, many (if not most) companies block 3rd party images and YouTube at the company firewall. As many of us are answering questions during our spare time at work these things are blocked.

NeoPa(...)It may be that the import is interpreting the first few lines as having numerics in that position and therefore fixes the field as numeric. (...)
I think you have "hit the nail on the head"

Fortunately I'm at home today so I could see Raymond's video. By default the import uses the first 8 or so records IIRC. The first five rows shown in the Excel opening show the values as right-hand alignment which is typical with numeric data and the remaining rows as left-hand which is typical for text/string data; thus, because the first five are numeric, and these are the predominate data type in the records read when the connection is made the parser guesses that the remaining values are numeric.

I have ran into this before with some instrument data and sample names. Some of these start with numeric values and some with alpha values. The data imports correctly if the first value encountered is alpha first for the first 10 or 20 sample names; however, if numeric first for the first 10 or so samples then it pukes (sometimes with just the first sample starting with numeric values!).

I ended up using IISAM and a schema information file to parse the text. Unfortunately, my references for this are at work; however, I did find an article at Database Journal: Working with external text files in MS Access covering this method - this is quite involved or I would post the steps directly.
PLEASE DO NOT EDIT YOUR REGISTRY as shown in the first part of the article - SKIP TO THE IISAM portion of the article.
- If you make an error in the registry you can make your OS fail beyond repair and while I will empathize with your pain should that happen... - you have been warned!

One thing to note... I make one schema information file in a "working" directory, use the FileCopy() to create a copy of the orginal data file in the "working" directory followed by Name()(click on the links for syntax) to rename the working copy of the file to a common name used within the schema information file (for ISO I cannot alter the filenames of the original data). Otherwise you have to create a schema information file for each file or build each file into the schema information file - I was importing hundreds of data-files so the standard naming method saved my sanity.

9 2234
twinnyfo
3,653 Expert Mod 2GB
Raymond RS,

Welcome to Bytes!

I am unfamiliar with the Error “Null”, but my initial guess is that your invoice number needs to be a numeric value, and during the import, since the values you show that are creating the error are alpha-numeric, these values are not accepted.

We would need a more detailed description of the exact error, the structure of your tables to which you are importing your data and any other pertinent information that can help us guide you to a better solution.
Aug 31 '18 #2
Hello Twinnyfo,

Thanks for the welcoming message. =)

Like you said, the field consist of Alpha-numeric data, that causes the problem. Following screenshot is showing the missing data from csv file and after imported to Access.



https://www.flickr.com/photos/156309.../shares/Hx2890

Thanks!
Aug 31 '18 #3
NeoPa
32,556 Expert Mod 16PB
Can we see a screenshot of the error message as displayed when you run the code please.
Aug 31 '18 #4
Hi Neopa,

The following is the video i make for the steps i went through...

https://youtu.be/ONR9phnNxOA

In fact there isn't any error messages... It just ignored on importing the data.

I understood it was because of alpha numeric data in the same field.. do you have any suggestion in overcoming this issue?
Sep 1 '18 #5
NeoPa
32,556 Expert Mod 16PB
Not at this point no. Still short of any info that leads to an understanding. I'm sure the video was an attempt to help with that, but showed very little of interest.

Two points :
  1. Try including the exact contents of your CSV file in here, within the [CODE] tags.
  2. Viewing the CSV using Excel may be the default, but it's frankly very little use to anyone (Particularly to you. Not just us). It gives very little idea of the actual data there.
From what you showed in both your pictures and your video, it seems like you have very few lines of data. Unfortunately that sort of thing's hard to determine just from a picture or the video. We only see what you think to show us.

I have a suspicion of what might be going wrong, but at this stage only that. It may be that the import is interpreting the first few lines as having numerics in that position and therefore fixes the field as numeric. Thus, once it hits data that isn't numeric - it fails to import it.

Once we see the data we can look at ways to get around it. That may require you to change the data somewhat. Is that within your power? Or is the data just something you have to deal with exactly as it is?
Sep 1 '18 #6
PhilOfWalton
1,430 Expert 1GB
As an experiment, try reversing the order of the lines in your CSV file so that it reads the Alpha value first.

Phil
Sep 1 '18 #7
zmbd
5,501 Expert Mod 4TB
Raymond,
Please keep in mind, many (if not most) companies block 3rd party images and YouTube at the company firewall. As many of us are answering questions during our spare time at work these things are blocked.

NeoPa(...)It may be that the import is interpreting the first few lines as having numerics in that position and therefore fixes the field as numeric. (...)
I think you have "hit the nail on the head"

Fortunately I'm at home today so I could see Raymond's video. By default the import uses the first 8 or so records IIRC. The first five rows shown in the Excel opening show the values as right-hand alignment which is typical with numeric data and the remaining rows as left-hand which is typical for text/string data; thus, because the first five are numeric, and these are the predominate data type in the records read when the connection is made the parser guesses that the remaining values are numeric.

I have ran into this before with some instrument data and sample names. Some of these start with numeric values and some with alpha values. The data imports correctly if the first value encountered is alpha first for the first 10 or 20 sample names; however, if numeric first for the first 10 or so samples then it pukes (sometimes with just the first sample starting with numeric values!).

I ended up using IISAM and a schema information file to parse the text. Unfortunately, my references for this are at work; however, I did find an article at Database Journal: Working with external text files in MS Access covering this method - this is quite involved or I would post the steps directly.
PLEASE DO NOT EDIT YOUR REGISTRY as shown in the first part of the article - SKIP TO THE IISAM portion of the article.
- If you make an error in the registry you can make your OS fail beyond repair and while I will empathize with your pain should that happen... - you have been warned!

One thing to note... I make one schema information file in a "working" directory, use the FileCopy() to create a copy of the orginal data file in the "working" directory followed by Name()(click on the links for syntax) to rename the working copy of the file to a common name used within the schema information file (for ISO I cannot alter the filenames of the original data). Otherwise you have to create a schema information file for each file or build each file into the schema information file - I was importing hundreds of data-files so the standard naming method saved my sanity.
Sep 1 '18 #8
Hi ZMBD,

My apology for not being considerate. In fact, I don't really know how to attach screenshot dirct in this site, as when I click the attachment button, the dialog box was asking to provide a URL link. So I uploaded to some free site and link it here. Do you have a screenshot guides on this? Thanks! =)

With regards of the issues. Thanks for your guidance! I have resolved my problem using the schema method.

I created a Schema.ini into the same folder and run the below code in MS Access, and it works perfectly for me.

Expand|Select|Wrap|Line Numbers
  1. Sub ImportSchemaTable()
  2.     Dim db As DAO.Database
  3.     Set db = CurrentDb()
  4.     db.Execute _
  5.     "SELECT * INTO test FROM [Text;FMT=CSVDelimited;HDR=Yes;DATABASE=C:\;].[test#csv];", dbFailOnError
  6.     db.TableDefs.Refresh
  7.     RefreshDatabaseWindow
  8. End Sub
  9.  
Again Thanks for your help ZMBD.

Also, Thanks NeoPa and PhilOfWalton for offering your suggestions too! =)
Sep 2 '18 #9
I have an issue with a fixed-width text file that I'm importing data into an existing database and I think I also got an issue with my system Asus S series laptop. I follow your instruction but still, I have an issue with it. I don't is that problem with database or System. So I contacted Asus Customer service to get Advice what happening to me.
Thanks for your guidance! I have resolved my problem using the schema method.
Sep 3 '18 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: atse | last post by:
Hi, I am still stick on the text file being imported to database. Can anybody help? I have just done the csv format files. And then I work on text and DAT formats, but I have problem to import...
0
by: adrian GREEMAN | last post by:
When I try to import a text file with new data for an existing table I get the error "1148 - the used command is not allowed with this MySQL version." I have tried with both PHPMyAdmin2.3 and...
3
by: Reed Loefgren | last post by:
I have moved 665 records off of Filemaker into mysql-4.0.18. I had a great deal of trouble exporting a text field, possibly because it had control characters that interferred with my field...
2
by: Hon Seng Phuah | last post by:
Hi all, I have a huge excel format file wants to export to sql server database. One of the field has combination of numeric and alphanumeric. When I import the excel format to sql server...
14
by: Manish | last post by:
The project I am developing doesn't involves database. I want to parse the mailbox file (.mbx) and store the summary in the text file for fast retrieval and display of information in the Inbox...
14
by: mfrsousa | last post by:
hi there, i have a huge large text file (350.000 lines) that i want to import to a MS Acccess Database, of course i don't want to use Access, but do it with C#. i already have tried the...
3
by: Ratan | last post by:
hi everybody, i want d code for d procedure to import data from excel sheet to db2 table. can anybody plz help me? its quite urgent. my mail id is ratan.nitrkl@gmail.com, yahoo chat id:...
4
by: Jeff | last post by:
Hey I'm wondering how the Fixed-Width Text Format is What I know is that the top line in this text format will contain column names. and each row beneath the top line represent for example a...
9
by: a | last post by:
Dear friends I want import data from CSV file to mdb file How can I do that in vb.net?
12
by: Miguel Valenzue | last post by:
I collect traffic data from a machine that outputs text files with the data. I want to import each text file as it's own table into an Access database and do it without having to run the import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.