How to create a table from CSV data

Video versionA video overview of CSV-based wpDataTables

Example of a CSV-based tablewpDataTables can be a WordPress CSV importer as well

The CSV, or “comma-separated-values” format is widely used; it’s simple, lightweight, almost any software can generate it, and users can even create it manually. Basically, it’s just a text file, where cells are separated with commas, rows are separated with new lines, and the first line contains table headers. CSV has been supported by wpDataTables since its first release.

You can download the file that was used to generate this table from this link. The table rendered from this file is below.

See the step-by-step tutorial below the table.

Country

Region

Grape

Size

Sweetness

Colour

Food match

Sweden

NI

Cinsaut

75CL

Semi-sweet

Gray

Vegetarian

Afghanistan

Saxony

Petit Verdot

75CL

Dry

White wine

Duck

Comoros

Goa

Mujuretuli

75CL

Dry

Rosé

Beef

Mauritania

Paraíba

Mujuretuli

1L

Sweet

Rosé

Duck

Maldives

North Island

Lagrein

1L

Very sweet

Rosé

Vegetarian

Argentina

Akwa Ibom

Aleatico

75CL

Bone dry

Gray

Fish

Croatia

Argyllshire

Aglianico

1L

Very sweet

White wine

Cheese

Isle of Man

LD

Garanoir

75CL

Sweet

Red wine

Cheese

Marshall Islands

Madhya Pradesh

Avanà

1L

Bone dry

Yellow

Vegetarian

Costa Rica

West Bengal

Gaglioppo

75CL

Sweet

Rosé

Cheese

Cyprus

South Island

Dureza

1L

Semi-sweet

Gray

Vegetarian

Portugal

Wie

Avanà

1L

Sweet

Gray

Beef

Afghanistan

Gelderland

Avanà

75CL

Semi-sweet

Yellow

Fish

Brazil

NA

Mujuretuli

75CL

Bone dry

Tawny

Fish

Venezuela

Koc

Lagrein

1L

Semi-sweet

Red wine

Cheese

Malta

Noord Brabant

Baga

75CL

Dry

Yellow

Duck

Eritrea

Zl

Manseng noir

75CL

Dry

White wine

BBQs

Guinea-Bissau

NI

Aglianico

1L

Dry

Yellow

BBQs

Sudan

GL

Mujuretuli

1L

Semi-sweet

Gray

Duck

Antarctica

Ist

Garanoir

75CL

Very sweet

Yellow

Fish

Ukraine

Kent

Avanà

1L

Semi-sweet

White wine

Cheese

Ireland

Hat

Blauburger

75CL

Semi-sweet

Gray

Duck

United States Minor Outlying Islands

North Island

Agiorgitiko

1L

Bone dry

Red wine

Fish

Brunei

HE

Aleatico

75CL

Sweet

White wine

BBQs

Korea, North

Mersin

Cinsaut

1L

Bone dry

Rosé

Fish

Slovakia

VII

Aleatico

75CL

Dry

Yellow

Cheese

Cameroon

Uttar Pradesh

Agiorgitiko

75CL

Semi-sweet

Gray

Pork

Dominica

Stockholms län

Petit Verdot

1L

Very sweet

Yellow

Beef

Faroe Islands

Queensland

Helfensteiner

75CL

Sweet

Rosé

Pork

Cayman Islands

QLD

Helfensteiner

75CL

Very sweet

Tawny

Vegetarian

Armenia

Vienna

AglianiconeAlbaranzeuli nero

75CL

Very sweet

Rosé

Beef

Iran

NB

Aragónez

75CL

Semi-sweet

Rosé

BBQs

Croatia

Andhra Pradesh

Gaglioppo

75CL

Very sweet

White wine

Pork

Antarctica

Andalucía

Agiorgitiko

75CL

Very sweet

Rosé

Pork

Switzerland

VEN

Petit Verdot

1L

Bone dry

Rosé

Cheese

Aruba

II

Garanoir

1L

Dry

Red wine

Cheese

Ukraine

NSW

Dureza

1L

Semi-sweet

Gray

Vegetarian

Puerto Rico

Leinster

Garanoir

1L

Very sweet

Gray

Fish

Chile

KC

Gaglioppo

75CL

Bone dry

Tawny

Vegetarian

Mozambique

Ankara

AglianiconeAlbaranzeuli nero

1L

Sweet

White wine

Vegetarian

Honduras

MP

Helfensteiner

75CL

Very sweet

White wine

Cheese

Saint Barthélemy

Gl

Baga

75CL

Very sweet

Tawny

Pork

Libya

AL

Manseng noir

1L

Dry

Red wine

Fish

Netherlands

U

Lagrein

1L

Very sweet

Gray

Cheese

Palestine, State of

Berlin

Agiorgitiko

1L

Very sweet

White wine

Pork

Falkland Islands

North Island

Gaglioppo

1L

Bone dry

Yellow

Cheese

Jamaica

Minas Gerais

Manseng noir

75CL

Bone dry

Tawny

Fish

Maldives

Western Australia

Petit Verdot

1L

Very sweet

Tawny

Beef

Solomon Islands

KN

Mujuretuli

1L

Semi-sweet

Red wine

BBQs

Luxembourg

Antwerpen

Baga

1L

Very sweet

Red wine

Duck

Sudan

CE

Mujuretuli

75CL

Dry

Rosé

BBQs

France

SJ

Gaglioppo

1L

Sweet

Rosé

Duck

Poland

BR

Blauburger

1L

Very sweet

Tawny

Vegetarian

South Georgia and The South Sandwich Islands

Bremen

AglianiconeAlbaranzeuli nero

1L

Dry

White wine

Vegetarian

Colombia

Noord Brabant

Manseng noir

1L

Very sweet

Gray

Duck

French Southern Territories

Victoria

Agiorgitiko

75CL

Semi-sweet

Yellow

Pork

Italy

Guanacaste

Aleatico

75CL

Dry

White wine

BBQs

Israel

W

Agiorgitiko

1L

Semi-sweet

Gray

Cheese

Paraguay

RM

Lagrein

75CL

Very sweet

Tawny

Duck

Bahamas

Noord Brabant

Cinsaut

1L

Semi-sweet

Yellow

BBQs

Yemen

RM

Manseng noir

1L

Dry

Red wine

Duck

United States

KP

Aglianico

75CL

Bone dry

Yellow

Vegetarian

Mali

Comunitat Valenciana

Blauburger

75CL

Dry

Gray

Beef

Swaziland

San José

Agiorgitiko

75CL

Dry

Red wine

Pork

Haiti

HH

Blauburger

1L

Dry

Tawny

Fish

Belize

PE

Helfensteiner

1L

Semi-sweet

Yellow

Duck

Virgin Islands, British

Nevada

Helfensteiner

75CL

Very sweet

Gray

Pork

Gabon

Z.

Agiorgitiko

75CL

Dry

Red wine

BBQs

Northern Mariana Islands

IA

Aglianico

75CL

Dry

Tawny

Duck

South Georgia and The South Sandwich Islands

Dolnośląskie

Agiorgitiko

1L

Semi-sweet

Red wine

Duck

Guadeloupe

Akwa Ibom

Garanoir

1L

Semi-sweet

Red wine

Duck

Macedonia

SP

AglianiconeAlbaranzeuli nero

75CL

Dry

White wine

Vegetarian

Liberia

Catalunya

Lagrein

1L

Very sweet

Yellow

Duck

Japan

QLD

Cinsaut

1L

Dry

Red wine

BBQs

Virgin Islands, United States

Gelderland

Cinsaut

75CL

Semi-sweet

Red wine

Beef

Korea, South

Berlin

Mujuretuli

1L

Semi-sweet

White wine

Cheese

Anguilla

OK

Aleatico

1L

Dry

White wine

Vegetarian

Bhutan

Mer

Helfensteiner

75CL

Dry

White wine

Cheese

Oman

Z.

Manseng noir

1L

Bone dry

White wine

Duck

Kazakhstan

DE

Dureza

75CL

Semi-sweet

Rosé

Vegetarian

Barbados

Andalucía

Manseng noir

1L

Very sweet

Yellow

Beef

Saudi Arabia

łódzkie

Agiorgitiko

1L

Very sweet

Yellow

Vegetarian

Isle of Man

KL

Avanà

1L

Dry

Rosé

Vegetarian

Guyana

L

Blauburger

1L

Very sweet

Rosé

Pork

Cook Islands

MA

Manseng noir

75CL

Dry

Red wine

Beef

Palau

Cumberland

Mujuretuli

75CL

Bone dry

Red wine

Pork

Canada

Valparaíso

Mujuretuli

75CL

Very sweet

White wine

Duck

Sao Tome and Principe

SP

Garanoir

1L

Very sweet

Tawny

BBQs

Eritrea

Zl

Garanoir

1L

Semi-sweet

Gray

Vegetarian

Eritrea

Nairnshire

Agiorgitiko

75CL

Semi-sweet

Yellow

Cheese

Croatia

Vlaams-Brabant

Aragónez

1L

Semi-sweet

Red wine

Duck

French Guiana

Stockholms län

Aragónez

1L

Sweet

White wine

Fish

Aruba

Nord-Pas-de-Calais

Petit Verdot

1L

Semi-sweet

Tawny

Vegetarian

Israel

Mississippi

Aglianico

75CL

Dry

Tawny

Pork

Jordan

NI

Avanà

75CL

Very sweet

White wine

Duck

Aruba

Stockholms län

Petit Verdot

1L

Dry

Rosé

Duck

French Southern Territories

L

Gaglioppo

75CL

Bone dry

Yellow

Vegetarian

Guyana

Manisa

Aleatico

1L

Sweet

Tawny

Vegetarian

Vanuatu

Alsace

Mujuretuli

1L

Bone dry

White wine

Fish

Indonesia

West-Vlaanderen

Lagrein

75CL

Semi-sweet

Gray

Cheese

Country

Region

Grape

Size

Sweetness

Colour

Food match

This format will work only up to a certain limit (no exact limit, but 3000-5000 cells is a good example). If you have a larger file, the page load time will increase. For large data sets it makes sense to import the data to MySQL, you can use “Create a table by importing data from data source” option to do this.

Instructions to create the table from CSV

The first thing you will need to do to create a CSV-based table in WordPress is to create the CSV file with your data set in your favorite software e.g., MS Excel, OpenOffice, LibreOffice, Numbers, Google Spreadsheet, or any other.

Save the file at a location where you can easily find it later.

Create a wpDataTable and upload your CSV file

After you saved the CSV file with your data, the next step is to go to your WordPress admin and create a new wpDataTable from the CSV data source.

Please open your WordPress admin, and:

1. Go to wpDataTables -> Create a Table, and choose Create a table linked to an existing data source option.

2. Set a name for your new wpDataTable that will help you to find the table later.
3. Choose CSV file as the Input data source type.
4. Click Browse… The WordPress Media Library pop-up will appear near the Input file.

5. Upload the CSV file you prepared in the Step 1, and click the Use selected file button.
6. Click Apply, so wpDataTables will read the CSV file you uploaded, and initialize the columns metadata.

Please note that your CSV file should be on the same domain as WordPress.

(Optional) - Define additional column and table settings

At this point table is already prepared. But to improve its usability, we need to define several additional settings for the table and its columns. For this case, we define these settings:

1. Enabled Limit table width checkbox and disable Table title checkbox on “Display” tab.
2. Set the Filter type for “Country“, “Region” and “Color” columns as “Select box”.
3. Set the Filter type for “Grape” and “Sweetness” columns as “Checkbox“.

Insert the wpDataTable in your page or post

When the configuration of your CSV-based wpDataTable is complete, you simply need to insert it to your post or page.

Open (or create a new) a WordPress post or page, place the cursor in the position where you want to insert your table, click the “Insert a wpDataTable” button in the MCE editor panel, and choose the CSV-based table that you prepared.

Or, if you prefer to do things manually, you can simply copy&paste the wpdatatable shortcode (you can find it in the wpDataTables browse page, or in wpDataTable edit page).

Never miss new features!

Join 2000+ newsletter subscribers

Never miss notifications about new cool features, promotions, giveaways or freebies - subscribe to our newsletter! We send about one mail per month, and do our best to keep our announcements interesting.