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 when exporting to csv #24

Open
MiniMinnoww opened this issue Sep 25, 2022 · 3 comments
Open

Error when exporting to csv #24

MiniMinnoww opened this issue Sep 25, 2022 · 3 comments

Comments

@MiniMinnoww
Copy link

When exporting to a csv file using this command:
sterra export -ssid {SSID} -u {Username} -t followers -f csv

I get an error saying
UnicodeEncodeError: 'charmap' codec can't encode characters in position 397-398: character maps to <undefined>

@novitae
Copy link
Owner

novitae commented Sep 25, 2022

Could you send the full traceback please ? I think it is probably a dumb encoding not specified error as described here, but I want to be sure

@MiniMinnoww
Copy link
Author

Could you send the full traceback please ? I think it is probably a dumb encoding not specified error as described here, but I want to be sure

Traceback (most recent call last): File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\Scripts\sterra.exe\__main__.py", line 7, in <module> File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\site-packages\sterra\core.py", line 432, in main ret = globals()[module.upper()](**kwargs) File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\site-packages\sterra\core.py", line 89, in EXPORT scrape(t,l) File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\site-packages\sterra\core.py", line 59, in scrape exporter(_=_, List=__a1List, file_path=file_path, Format=Format, **{"username":username,"target":targlist})() File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\site-packages\sterra\filerra.py", line 20, in __call__ getattr(self,self.Format.upper())() File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\site-packages\sterra\filerra.py", line 57, in CSV w.write(','.join(self.dict_keys)+'\n'+"\n".join([",".join([str(v).replace('\n','</b>').replace(',','</c>') for v in d.values()]) for d in self.list])) File "C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 397-398: character maps to <undefined>

@novitae
Copy link
Owner

novitae commented Sep 25, 2022

I'm currently working on the v3 so I won't push correction for now, what you can do is

  • At C:\Users\fishy\AppData\Local\Programs\Python\Python39\lib\site-packages\sterra\filerra.py, line 57 replace this
w.write(','.join(self.dict_keys)+'\n'+"\n".join([",".join([str(v).replace('\n','</b>').replace(',','</c>') for v in d.values()]) for d in self.list]))
  • By that:
w.write(','.join(self.dict_keys)+'\n'+"\n".join([",".join([str(v).replace('\n','</b>').replace(',','</c>') for v in d.values()]) for d in self.list]), encoding="utf-8")

Tell me if it works or not

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