VBA Access Transfertext Import Errors - vba

I would like to import a spreadsheet to an access database, on column has ages 1-89 plus another that's says 90+ which in turn create a Import Error. Using the DoCmd.TransferText, is it possible to import everything as it is including 90+ in the column of all other numbers?

If you import data into a table that doesn't already exist, Access will create one for you. It automatically determines the data type of each column based on the first few rows that are imported. If your source data contains a mixture of data types in one column, then you may experience this error.
There are 2 solutions:
Build the import table to be of the correct data type for your data (i.e. specify that the age column is Short Text). Then import to the pre-defined import table.
Ensure that the CSV or Excel file stores each age as a string i.e. "20" instead of 20 (in Excel, format the cell as Text, so it is left aligned or start cell contents with an apostrophe '20 or use formulaic notation ="20").
You could do either of those things, but it would be better to do both of them if possible.

Related

Google BigQuery Import csv Using Console - Use first row as header

I have a csv file with 1 column which I want to import into my big query environment. When using the Console to import data - always take my first row as a data row rather than a column name. Is there a way in the console to always ensure the first row is always the column name
E.g.
Tk Number
Tk - 0001
Tk - 0002
In CSV format, if the first row is string and others are integers, then it automatically takes the first row as header name, if you have checked the auto-detect schema option while creating the table.
But since you have strings in header as well as body, you will need to give the schema manually while creating the table in BigQuery. And in advanced options you can specify the number of rows to be skipped under 'header rows to skip' option.

Import CSV with Dynamic Columns

My Vendor is providing a CSV file where columns (names included on first line) are dynamic - meaning they will only appear if there is data in them and there is no guarantee on the order the columns will be provided
I am looking to understand the best approach to take to import such a horrible file.
Using the FileHelpers.net and optional fields.. but the issue with this is that the column orders can change
You can build a FileHelpers class on the fly, then use that with the engine to import the CSV. If you import as a DataTable, you would then be able to check if a column exists and populate your database using that or doing whatever you need to with this columns.

Import a CSV file into Access using VBA

I need to use VBA to import a large CSV excel file into an Access table. The delimiter is "" (double quotes) except for some reason the first value is followed by " (only one quote) instead of two like every other value. The first row contains the column headers and are delimited the same way. At the bottom I have attached an example.
The CSV files are generated automatically by an accounting system daily so I cannot change the format. They are also quite large (150,000+ lines, many columns). I'm fairly new to VBA, so as much detail as is possible would be much appreciated.
Thanks in advance!
Example of format
That doesn't sound like a CSV file. Can you open it in Excel, convert it to a true CSV, and then import that into Access? You will find many VBA-driven import options at the URL below.
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm
Also, take a look at these URLs.
http://www.erlandsendata.no/english/index.php?d=envbadacimportado
http://www.erlandsendata.no/english/index.php?d=envbadacimportdao

Preparing excel workbook for importing into SQL

I am trying to import some data into sql using the import and export data wizard. In excel i have a column with 8 numbers. However when i get these in the import wizard said column is displayed as being double. and when i import it i get overflow errors. I then go back to excel, select the cell, format them as being a number with no decimal places. Then i go to the "edit mappings" in the import wizard and change the destination to numeric(8,0). I get those overflow errors as well.
Would like if i could get a way to better format the data in excels to import better
Thank You
You can import your table into a temp or staging table with a larger data type; validate and clean your imported data; then load it into your real table. If you can't always enforce the data type in your Excel doc, then make it easier on the server side to import your data, then manipulate it there.
I had a project that ran into this problem last year.
What I ended up doing is I imported the data from Excel to Access. Then import from Access to SQL. I don't remember the specifics, but it solved most of my issues.
I don't think the format of the column in Excel makes a difference to the import process (although I could be wrong about that.)
My guess would be that either one of your numbers is 9 or more digits, or one of them has a very small fractional component that's small enough not to appear in Excel but which the wizard detects.
You're certain that this column is the one with the overflow errors, by the way? Does it tell you what row has the problem?

Importing data from excel and inserting into sql tables

I am Importing data from excel and inserting into a sql table. One of the fields in my Excel file is populated with a time value. I want to import that time value as a string into my sql table. When i do that i get a weird value in my sql table. Excel value is: 07:00 and after inserting that as a string into the sql table the time values looks like this: 0,29166666667.
The reason for importing it as a string value is that you have to be able to define Days in the same field. Like this : D2 10:30. When i import this kind of values it is inserted correctly.
can anyone help ?
Excel stores dates and times as number-values from 0 to 0.99999999 +x days.
0.29166666667 would be like 00.01.1900 07:00:00, which seems to be correct in your case.
So, you would have to use some reformatting or conversion of this value, before using it as a direct string-input.
In VBA you could use Format(myValue,"DD-MM-YYYY hh:mm:ss").
The equivalent worksheet function would be TEXT(A1,"DD-MM-YYYY hh:mm:ss").
The format-code depends on your regional settings. You might want to try something like this Format(myTime, "Long Time"), if you preffer to use excel-defined time-formats.
Because you did not post any code, I am not sure about how you import your excel-data. But I would say, the fastest way to get better results, would be setting up a new column, using the TEXT formula with a reference to the previously time-column and use this new formatted column as input for your sql-db.