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

Reference to invalid character number: line 38, column 137 #5

Open
Doofitator opened this issue Dec 5, 2018 · 2 comments
Open

Reference to invalid character number: line 38, column 137 #5

Doofitator opened this issue Dec 5, 2018 · 2 comments

Comments

@Doofitator
Copy link

When attempting to run the script, I get the following output:

[nemo@Sailfish ~]$ python sms_import.py --import sms-20181206090639.xml 
Traceback (most recent call last):
  File "sms_import.py", line 13, in <module>
    sms_list = parser.get_all_sms_in_sf_format()
  File "/home/nemo/sail_sms.py", line 31, in get_all_sms_in_sf_format
    xmldom = minidom.parse(self.xml_file)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1918, in parse
    return expatbuilder.parse(file)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 924, in parse
    result = builder.parseFile(fp)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 207, in parseFile
    parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: reference to invalid character number: line 38, column 137

I don't know what xml.parsers.expat.ExpatError is, but I've played with Python before. If you don't want to / don't have time to fix it, could you at least point me in the right direction so I can try?

@ak1nola
Copy link

ak1nola commented Jan 4, 2019

I had a similar issue a few minutes ago. You can fix easily - there's an argument for it been a data problem than a bug.

  • open up the xml file in an editor - I'll go with an editor that shows line numbers and column numbers e.g. visual studio code
  • search for line 38, and column 137 and most likely simply remove the character in question.
  • copy the updated file back to your phone and run the script

In my case the issue was emoji that most likely the xml python parser didn't interpret as valid xml code e.g. & #55357;& #56866; for 😢. I ended up just using a regex pattern to replace all such occurrences because I had over 300 such emoji/emoticons in my exported xml file.

@Doofitator
Copy link
Author

Wow. Brilliant - I'll try that out. It never clicked that it could have to do with my export file rather than the python itself. Thank you.

I understand that you believe this should be a data error, not a bug, however a good script would gracefully handle this error, not cut out with cryptic developer messages like this. In a perfect world, this program would explain what you just did to the user to justify the error, or better yet, perform the corrections itself. If I ever get the chance and someone hasn't bet me to it, I'll have a whirl at the latter and see if I can send a pull request.

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