harelba / q

q - Run SQL directly on delimited files and multi-file sqlite databases

Home Page:http://harelba.github.io/q/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use -C throw some error

coderpolo opened this issue · comments

image

how can i slove it?

os:ubuntu 20.04

Hi,

Thanks for reporting this.

The error is related to the encoding of the data, either the original file or the created qsql file.

The default chosen -e value is set according to your terminal encoding (which seems to be latin-1).

It would be great if you can provide the following information so I can analyze this:

  • Can you run file tmp (the original text file) and send the output of the command?
  • Can you provide the output of ls -ltr tmp* - So both the cache file and the original file will be shown
  • Can you run the same command you wrote above (with -C read), but add another flag for the execution - -e utf-8?
  • Did you run the command which created the qsql file (the one using -C readwrite) from the same terminal or from another computer/terminal (perhaps with another default encoding).

Did you run the command which created the qsql file (the one using -C readwrite) from the same terminal or from another computer/terminal (perhaps with another default encoding).

yes, the file named "tmp" was generated by another computer.
Thanks!

Does running with -e utf-8 (or whatever the encoding is on the other computer) work properly?

I probably need to be able to guard against such things, and store the db-creation encoding in the qsql file itself

the quary not worked.
image
but the qsql file was auto generated.

I use "cat tmp > tmpX "
and run query "select count(*) from tmpX" to slove this problem...

just for future reference - The reason is a difference between the terminal encoding and the data encoding. By default, q assumes that the file encoding is the same as the terminal encoding. If that's not the case, you'd need to use -e <encoding> in order to tell q the right encoding of the data.