CSV File

Display your CSV file in an interactive DataView in three steps:

  1. Upload a CSV to your site
  2. Pass the CSV absolute path to DataKit SDK
  3. Embed a shortcode.

Demo of displaying a CSV in a table

We have a CSV file of Oscar winners for Best Actor through 2024. We uploaded it to the site and rendered it with DataKit SDK:

It just took a few lines of code:

PHP
$csv_data_source = new CsvDataSource( '[file path]/oscar-example-data.csv' );
	
	$oscar_winner_best_actor = DataView::table(
		'csv-demo',
		$csv_data_source,
		[
			TextField::create( 1, 'Year' ),
			TextField::create( 2, 'Age' ),
			TextField::create( 3, 'Name' ),
			TextField::create( 4, 'Movie' ),
		],
		Sort::desc( 'Year' )
	)->paginate( 10 );

	do_action( 'datakit/dataview/register', $oscar_winner_best_actor );

Your CSV that you’re trying to display? Similarly easy with DataKit.


Discover more from DataKit

Subscribe to get the latest posts and announcements sent to your email.