Execute SQL on CSV files via JDBC

前端 未结 7 1742
后悔当初
后悔当初 2020-12-28 19:46

I need to apply an SQL query to CSV files (comma-separated text files). My SQL is predefined from another tool, and is not eligible to change. It may contain embedded select

7条回答
  •  心在旅途
    2020-12-28 20:11

    There is a Groovy script, gcsvsql that lets you treat csv files as database tables, including joins. With gcsvsql you can do things like:

    gcsvsql "select * from people.csv where age > 40"

    gcsvsql "select people.name,children.child from people.csv,children.csv where people.name=children.name"

    gcsvsql "select avg(score) from people.csv where age < 40"

    You can find this script, which is based on the h2 database engine, at Google code here:

    http://code.google.com/p/gcsvsql/

提交回复
热议问题