Question

how to create .mdb from structure format in excel file?


Badge +5

Hi all,

I need to create a .mdb access file from excel file which have informations about field name, width and type datal. Could you tell me how to make it from FME workbench?

This is my excel data (input). I want to make 4 columns in .mdb with type, width data the same here.


10 replies

Userlevel 2
Badge +17

Hi @hoa_le, if you want to create a *.mdb file that contains an empty table with the fixed four fields, a possible way is:

  1. FeatureWriter: Configure the schema and write a single feature temporarily into a new table (e.g. "new_table").
  2. SQLExecutor: Delete all records from the new table.

The workflow on the Canvas looks like this.

Badge +5

Hi Takashi,

If my excel file have 200 field name which I want to create. I can't make manual, so could you tell me how to way to import excel file description for each field to .mdb by automatically?

Thank you

Userlevel 2
Badge +17

You can create an attribute storing a SQL CREATE TABLE statement based on the field definitions read from the Excel table, and then execute the statement with a SQLExecutor. Just be aware that the dataset (i.e. *.mdb file) must exist when executing the SQL statement to create a table.

A basic CREATE TABLE statement looks like this.

create table new_table (
name char(12),
ages integer,
province char(30),
Mark integer
);
Userlevel 2
Badge +17

You can create an attribute storing a SQL CREATE TABLE statement based on the field definitions read from the Excel table, and then execute the statement with a SQLExecutor. Just be aware that the dataset (i.e. *.mdb file) must exist when executing the SQL statement to create a table.

A basic CREATE TABLE statement looks like this.

create table new_table (
name char(12),
ages integer,
province char(30),
Mark integer
);
See also the attached example: create-mdb-table.fmwt (FME 2017.0.1.1)

 

 

Badge +5

Thank you so much Takashi.

In FME has not exist double, float type? Can change the same type double, float by?

Userlevel 2
Badge +17

Thank you so much Takashi.

In FME has not exist double, float type? Can change the same type double, float by?

Set of available native data types depends on database engine. For Microsoft Access database, you can see a list of data types here.

 

https://support.office.com/en-us/article/SQL-Data-Types-9188f41d-6c0e-4733-9d20-d08916f50bd2

 

Note: char(n) is an alias of text(n).

 

 

Basically FME can map every native data type of all supported database formats to FME generic data type.
Badge +5

Thank you Takashi. If String type, I see that replace by char. But with Float and double type. What type will be replace?

Userlevel 2
Badge +17

Thank you Takashi. If String type, I see that replace by char. But with Float and double type. What type will be replace?

I guess that both are floating point number types.

 

See again the list of Access SQL data types I've linked previously.

 

https://support.office.com/en-us/article/SQL-Data-Types-9188f41d-6c0e-4733-9d20-d08916f50bd2

 

You can see these two types for floating point number.

 

  • REAL: 4 bytes single-precision floating-point number (SINGLE is an alias)
  • FLOAT: 8 bytes double-precision floating-point number (DOUBLE is an alias).
Replace your "Float" and "double" with appropriate data types above according to their meanings (i.e. number of bytes and/or precision).

 

Userlevel 2
Badge +17

Thank you Takashi. If String type, I see that replace by char. But with Float and double type. What type will be replace?

In addition, you can also see three integer types in the list - TINYINT, SMALLINT, and INTEGER. In the previous answer, I suggested INTEGER to replace "int", but it would be wrong if your "int" does not mean 4 bytes integer type. You should determine the most appropriate integer type to replace your "int" with.

 

Badge +5

Thank you Takashi. If String type, I see that replace by char. But with Float and double type. What type will be replace?

 

Thank you so much. I will use number type :)

Reply