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

Error while creating html report with eda_process: 'charmap' codec can't encode character #977

Open
caisdosodre opened this issue Mar 26, 2024 · 0 comments

Comments

@caisdosodre
Copy link

Describe the bug
My code is below:

import neurokit2 as nk
import pandas as pd
data1=pd.read_csv("sample.csv", names=["EDA"])
signals, info = nk.eda_process(data1["EDA"], sampling_rate=100, report="report.html")

Output:

The raw signal, sampled at 100 Hz, was cleaned using the default method of the neurokit2 package.

The signal was decomposed into phasic and tonic components using the method described in neurokit.

The cleaned signal was used to detect peaks using the default method of the `neurokit2` package.



References
- https://doi.org/10.21105/joss.01667
The report has been saved to report.html
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
Cell In[23], [line 1](vscode-notebook-cell:?execution_count=23&line=1)
----> [1](vscode-notebook-cell:?execution_count=23&line=1) signals, info = nk.eda_process(data1["EDA"], sampling_rate=100, report="report.html")

File [c:\Python312\Lib\site-packages\neurokit2\eda\eda_process.py:134](file:///C:/Python312/Lib/site-packages/neurokit2/eda/eda_process.py:134), in eda_process(eda_signal, sampling_rate, method, report, **kwargs)
    [132](file:///C:/Python312/Lib/site-packages/neurokit2/eda/eda_process.py:132)     else:
    [133](file:///C:/Python312/Lib/site-packages/neurokit2/eda/eda_process.py:133)         fig = None
--> [134](file:///C:/Python312/Lib/site-packages/neurokit2/eda/eda_process.py:134)     create_report(file=report, signals=signals, info=methods, fig=fig)
    [136](file:///C:/Python312/Lib/site-packages/neurokit2/eda/eda_process.py:136) return signals, info

File [c:\Python312\Lib\site-packages\neurokit2\misc\report.py:71](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:71), in create_report(file, signals, info, fig)
     [69](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:69) print(f"The report has been saved to {file}")
     [70](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:70) contents = [description, table_html, fig_html, ref]
---> [71](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:71) html_save(contents=contents, file=file)

File [c:\Python312\Lib\site-packages\neurokit2\misc\report.py:181](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:181), in html_save(contents, file)
    [178](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:178)     else:
    [179](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:179)         # assume the content is an interactive plotly figure and export to HTML
    [180](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:180)         inner_html = content.to_html().split("<body>")[1].split("</body>")[0]
--> [181](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:181)     page.write(inner_html)
    [182](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:182)     page.write("<br>")
    [183](file:///C:/Python312/Lib/site-packages/neurokit2/misc/report.py:183) page.write("</body></html>" + "\n")

File [c:\Python312\Lib\encodings\cp1252.py:19](file:///C:/Python312/Lib/encodings/cp1252.py:19), in IncrementalEncoder.encode(self, input, final)
     [18](file:///C:/Python312/Lib/encodings/cp1252.py:18) def encode(self, input, final=False):
---> [19](file:///C:/Python312/Lib/encodings/cp1252.py:19)     return codecs.charmap_encode(input,self.errors,encoding_table)[0]

UnicodeEncodeError: 'charmap' codec can't encode character '\u25c4' in position 291500: character maps to <undefined>

Expected behaviour
HTML report output

Screenshots
same as output

System Specifications

It's important that you give us some information about the system you are using. For that you can run:

import neurokit2 as nk
nk.version()
  • OS: Windows (WindowsPE 64bit)

  • Python: 3.12.1

  • NeuroKit2: 0.2.7

  • NumPy: 1.26.4

  • Pandas: 2.2.1

  • SciPy: 1.12.0

  • sklearn: 1.4.1.post1

  • matplotlib: 3.8.3

Running on ipynb notebook in VSCode

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

1 participant