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
Support none ASCII characters in create_assignments from csv. #9
Comments
Hi @hmelendez I cannot open the text file in python (defaults to UTF-8 encoding); it seems to be in a different encoding than UTF-8? Do you what encoding it is in? I added some non-ascii characters to a UTF-8 encoded CSV file and was able to create the assignments as expected. I cannot reproduce your issue. My simple csv
Output on workforce app:I'm guessing it's something to do with how your csv file is encoded, but I'm not sure. Can you post a screenshot of what you see after creation and how they are jumbled? |
In other scripts/apps, I load files using iso-8859-1 and it load acute characters.
|
Thanks @MikeMillerGIS that worked. @hmelendez I was able to import your text file of assignments by doing: with open(csvFile, 'r', encoding='iso-8859-1') as file:
reader = csv.DictReader(file)
for row in reader:
assignments_in_csv.append(row) Then in workforce they seem correct: Does that look correct? It seems to match the txt file you provided. Can you try using |
Okay so I looked into this a bit more. The first file you provided appears to be encoded as ANSI (at least that's what notepad++ sniffed from it) so you should probably use The second file you provided appears to be encoded as UTF-8 (at least that's what notepad++ sniffed from it) so you should use Reading today_assignments.txt with UTF-8 encodingAs far as I know there's no reliable way to determine the encoding of the file though there as some heuristics that can be used. Chardet is a library that can detect the encoding using such heuristics. You could try incorporating this library if you have to routinely read CSV files with different encodings. You could also look into how the CSV files are generated and ensure they are the same encoding. |
Hi. I'm using export_assignments_to_csv and suddenly started getting the below - any advice appreciated. I can't find the character reported anywhere in my Assignments (was expecting it to be in Notes left by Workers but, alas not). Thanks in advance! Jonathan [2017-06-10 09:14:48,319] [ export_assignments_to_csv.py: 115 - main()] [MainThread] [ root] [ INFO] Authenticating... ^bump |
Closing. The scripts assume UTF-8 encoding of CSV files. If your csv files use a different encoding then you need to specify that in the script. |
My Description field has none ascii characters (á,é,í,ó,ú). The arcgis_api create_assignments_from_csv python creats the assignments but the Description filed scribles the words with does none ascii characters. I've atached a sample.
my_assignments.txt
The text was updated successfully, but these errors were encountered: