turbot / steampipe-plugin-csv

Use SQL to instantly query data from CSV files. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/csv
Apache License 2.0
19 stars 4 forks source link

Empty CSV file seems to be problematic when loading #60

Closed e-gineer closed 1 year ago

e-gineer commented 1 year ago

Create an empty CSV file:

touch empty.csv

With v0.19.5 I saw some problems loading it:

/tmp/crap $ steampipe query
Welcome to Steampipe v0.19.5
For more information, type .help
Warning: failed to start plugin 'hub.steampipe.io/plugins/turbot/csv@latest': failed to parse file header /tmp/crap/empty.csv: EOF
> .inspect csv
Error: could not find connection or table called 'csv'. Is the plugin installed? Is the connection configured?
> 

I also saw different issues using it with v0.20.2. For v0.20.2 I recommend checking the hash status in the connection state table as part of testing. I saw that behavior a little unpredictable too (which is more of a steampipe CLI issue, but worth noting as it can be confusing when trying to pin down issues).

/tmp/crap $ steampipe query
Welcome to Steampipe v0.20.2
For more information, type .help
> select * from steampipe_connection_state where name = 'csv'
+------+-------+------+---------------+--------+--------------------------------------------+-------------+----------------------------------+--------------+---------------------------+---------------------------+
| name | state | type | import_schema | error  | plugin                                     | schema_mode | schema_hash                      | comments_set | connection_mod_time       | plugin_mod_time           |
+------+-------+------+---------------+--------+--------------------------------------------+-------------+----------------------------------+--------------+---------------------------+---------------------------+
| csv  | ready |      | enabled       | <null> | hub.steampipe.io/plugins/turbot/csv@latest | dynamic     | 6c368b2c8e93381d7c35de58620b72ea | true         | 2023-05-26T15:09:01-04:00 | 2023-05-15T09:04:32-04:00 |
+------+-------+------+---------------+--------+--------------------------------------------+-------------+----------------------------------+--------------+---------------------------+---------------------------+
> .inspect csv
+----------------+------------------------------------------+
| table          | description                              |
+----------------+------------------------------------------+
| country        | CSV file at /tmp/crap/country.csv        |
| json-not-csv-2 | CSV file at /tmp/crap/json-not-csv-2.csv |
| state          | CSV file at /tmp/crap/state.csv          |
+----------------+------------------------------------------+
>