SkillAgentSearch skills...

Csv2sql

Convert CSV to SQL

Install / Use

/learn @hay/Csv2sql
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

csv2sql

Introduction

A very simple PHP script that converts a CSV file to a SQL dump. The script expects the CSV file to be in a proper format that is readable to PHP's fgetcsv.

All values should be enclosed in double quotes (") and seperated by commas (,). Furtheremore, the first line of your file is used for the names of the rows.

Here's a simple example of a proper CSV file:

"id", "book", "author"
"1", "1984", "George Orwell"
"2", "Hamlet", "Shakespeare"

Usage

  1. Make this command executable

    chmod +x ./csv2sql

  2. Use it from the commandline like this

    csv2sql file.csv table_name

The output will go to stdout, so to write it to a file do something like this:

csv2sql file.csv table_name > import.sql

Credits

Written by Hay Kranen (@hayify).

Patches and comments welcome on Github

View on GitHub
GitHub Stars4
CategoryData
Updated3y ago
Forks4

Languages

PHP

Security Score

50/100

Audited on Jan 28, 2023

No findings