noborus / trdsql

CLI tool that can execute SQL queries on CSV, LTSV, JSON, YAML and TBLN. Can output to various formats.
https://noborus.github.io/trdsql/
MIT License
1.93k stars 72 forks source link

CSV Column Name not recognized #277

Open neoramos opened 2 months ago

neoramos commented 2 months ago

I'm not sure what I'm doing wrong.

I'm trying to read from a csv with the columns Engine_name, Variable_name and Value. However, for some reason the Engine_name column is not recognized as a header column. Here are the queries I tried: Get some of in on the data to confirm the data is there: trdsql -ih -a mysql_5.7.x_settings.csv Output: The table name is mysql_5.7.x_settings.csv. The file type is CSV.

Data types: +-------------------+------+ | column name | type | +-------------------+------+ | `Engine_name` | text | | `Variable_name` | text | | `Value` | text | +-------------------+------+

Data samples: +-----------------+---------------------------------------+-------------------------------+ | `Engine_name` | `Variable_name` | `Value` | +-----------------+---------------------------------------+-------------------------------+ | MySQL 5.7.X | aurora_backtrace_compare_metrics_file | backtrace_compare_metrics.txt | +-----------------+---------------------------------------+-------------------------------+

Examples: trdsql -ih "SELECT `Engine_name`, `Variable_name`, `Value` FROM mysql_5.7.x_settings.csv" trdsql -ih "SELECT `Engine_name`, `Variable_name`, `Value` FROM mysql_5.7.x_settings.csv WHERE `Engine_name` = 'MySQL 5.7.X'" trdsql -ih "SELECT `Engine_name`, count(`Engine_name`) FROM mysql_5.7.x_settings.csv GROUP BY `Engine_name`" trdsql -ih "SELECT `Engine_name`, `Variable_name`, `Value` FROM mysql_5.7.x_settings.csv ORDER BY `Engine_name` LIMIT 10"

I tried: trdsql -ih "SELECT `Engine_name`, `Variable_name`, `Value` FROM mysql_5.7.x_settings.csv ORDER BY `Engine_name` LIMIT 10" 2024/04/17 09:29:08 export: no such column: Engine_name [SELECT Engine_name, Variable_name, Value FROM mysql_5.7.x_settings.csv ORDER BY Engine_name LIMIT 10]

I tried: trdsql -ih "SELECT Engine_name, Variable_name, Value FROM mysql_5.7.x_settings.csv" 2024/04/17 09:29:27 export: no such column: Engine_name [SELECT Engine_name, Variable_name, Value FROM mysql_5.7.x_settings.csv]

Btw, great job on this tool. I just started using and sharing it internally.

noborus commented 2 months ago

Thank you for writing the issue.

I tried doing the same thing, but it didn't reproduce.

trdsql -ih "SELECT Engine_name, Variable_name, Value FROM mysql_5.7.x_settings.csv" 
MySQL 5.7.X, aurora_backtrace_compare_metrics_file, backtrace_compare_metrics.txt

You may be able to find the cause by running it with -debug.

trdsql -debug -ih "SELECT Engine_name, Variable_name, Value FROM mysql_5.7.x_settings.csv"