q icon indicating copy to clipboard operation
q copied to clipboard

use -C throw some error

Open coderpolo opened this issue 3 years ago • 5 comments

image

how can i slove it?

os:ubuntu 20.04

coderpolo avatar Feb 22 '22 03:02 coderpolo

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).

harelba avatar Feb 22 '22 12:02 harelba

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!

coderpolo avatar Feb 22 '22 14:02 coderpolo

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

harelba avatar Feb 22 '22 18:02 harelba

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

coderpolo avatar Feb 23 '22 05:02 coderpolo

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

coderpolo avatar Feb 23 '22 05:02 coderpolo

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.

harelba avatar Aug 12 '22 11:08 harelba