Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can’t open the file if the filename contains chinese. #55

Closed
ican0 opened this issue Feb 27, 2020 · 6 comments
Closed

can’t open the file if the filename contains chinese. #55

ican0 opened this issue Feb 27, 2020 · 6 comments

Comments

@ican0
Copy link

ican0 commented Feb 27, 2020

The pyDatView is wonderful. Thanks for the ebranlard's work.
But there are two bugs, they are both because of the chinese.

  1. if the filename contains chinese, then there is an error when open the file.
    image
  2. usually the fisrt line in data file is the column name. If the column name contains chinese, then the chinese in picture cannot show .
    image
@ebranlard
Copy link
Owner

ebranlard commented Feb 28, 2020 via email

@ebranlard
Copy link
Owner

ebranlard commented Feb 28, 2020 via email

@ican0
Copy link
Author

ican0 commented Mar 1, 2020

Glad for your reply.
1)the file "normal.csv" and "normal - 副本.csv" have the same content. The only difference is the file name. You can have a test with them.
2)The versions that I use are pyDatView_v0.1-235-dev_portable.zip and pyDatView_v0.1-238-dev_portable.zip
And I think the key is python‘s features:the python does not support for chinese as well as english.

example.zip

By the way, there are two style now: the scatter and the line. If you could add the third style "scatter + line", it could be better.
Thanks a lot!

@ebranlard
Copy link
Owner

ebranlard commented Mar 3, 2020

Hi,

Can you try the latest release version (version 242)?

Issue 1: Opening files with unicode characters in them. The issue should be fixed now, it seemed to be a pandas issue.

Issue 2: Pyplot does not support chinese characters. I fixed this issue, but it requires you to install a font. What I'm doing is detecting potential special characters in labels, and then applying the font "SimHei" (which seems to be the one people tend to use). For it to work, you need to download the font from here, and then you can place this file either:

  • at the root of the pyDatView folder

    • If you used a setup.exe, that would be by default in C:\Users\XXX\AppData\Local\pyDatView\pkgs\
    • If you cloned the repository: that would be, next to pyDatView.py
  • or in your matplotlib data font folder.

    • If you used a setup.exe, that would be by default in
      C:\Users\XXX\AppData\Local\pyDatView\pkgs\matplotlib\mpl-data\fonts\ttf
    • If you cloned the repository, the script below will indicate you where to put the font file.
import os
import matplotlib
fpath = os.path.join(matplotlib.rcParams['datapath'], 'fonts/ttf/SimHei.ttf')
print('Matplotlib data path   : ', matplotlib.rcParams['datapath'])
print('New font file should be: ', fpath)
if os.path.exists(fpath):
    print('[ OK ] Font is found')
else:
    print('[FAIL] Font not found. Add it to the path above. )')

Let me know if that works for you. It should look like that:

image

@ican0
Copy link
Author

ican0 commented Mar 3, 2020

Nice work! It works well now.Thanks a lot!

By the way, there are two style now: the scatter and the line. If you could add the third style "scatter + line", it could be better.

@ebranlard
Copy link
Owner

Hi @ican0, you can now use "Plain" lines, "different line styles (LS)" or scatter, to plot data. I haven't implemented scatter +line or line + scatter. But I hope to let the users chose their styling in (#52), when I get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants