PHP Classes

PHP CSV to Data Dictionary: Generate data dictionary from CSV file

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 315 All time: 7,210 This week: 220Up
Version License PHP version Categories
csv-dictionary 1.0GNU General Publi...5PHP 5, Databases, Files and Folders
Description Author

This class can generate data dictionary from CSV file.

It parses the CSV file and attempts to detect the types of data on each column. It can detect text strings, integers, floats and booleans.

The class can optionally extract the field names from the header row.

It can also generate a SQL query to create a table with the structure of fields of the detected types, as well SQL insert statements to to insert the parsed data into the table rows.

The class can also output the data dictionary in a human readable format on a Web page.

Innovation Award
PHP Programming Innovation award winner
July 2015

Prize: One subscription to the PDF edition of the PHP Architect magazine
Many applications can import data exported by other programs in the CSV format.

When you want to import CSV data into a database, you need to create the necessary tables to insert the records of CSV data.

This class can help performing that task by examining a CSV file to determine the names and types of the fields of the records of the table to be created.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 56
All time rank: 679 in United States United States
Week rank: 17 Up1 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Class: csvdict
Version: 1.0 5/15/2015

Copyright 2015 Wagon Trader

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.


This class generates a data dictionary from data supplied in a csv file.

It can display a human readable data dictionary.

It can return the SQL query statement to create the database table.

It can return the SQL query statements to insert the data into the table.


csvdict.class.php - Main class

example.php - Example usage script

sample.csv - Sample csv file


Upload files to a web accessible location on your server (eg. public_html)


The class is configured to work with most server configurations.


The included example.php file includes examples on instantiating the class and basic operation instructions.

Complete method usage is documented in the class.
  Files folder image Files  
File Role Description
Plain text file csvdict.class.php Class Main Class
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Accessible without login Plain text file manual.txt Doc. Documentation
Accessible without login Plain text file sample.csv Data Sample data

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,210
This week:220Up
For more information send a message to info at phpclasses dot org.