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

Excel export files require repair #514

Closed
kerchner opened this issue Nov 3, 2016 · 15 comments
Closed

Excel export files require repair #514

kerchner opened this issue Nov 3, 2016 · 15 comments

Comments

@kerchner
Copy link
Member

kerchner commented Nov 3, 2016

Opening every Excel export from SFM on my Mac consistently results in
exporterror

The file can be repaired and seems to behave well after that, but we are probably not creating it correctly.

@kerchner kerchner added the bug label Nov 3, 2016
@kerchner kerchner added this to the 1.4 milestone Nov 3, 2016
@kerchner
Copy link
Member Author

kerchner commented Nov 3, 2016

@adityadharne you noted a problem with JSON exports, can you describe it here?

@adityadharne
Copy link
Contributor

This the error I get:
screenshot from 2016-11-03 12 15 56

@kerchner
Copy link
Member Author

kerchner commented Nov 3, 2016

@adityadharne Which application are you using to open to JSON document?

@adityadharne
Copy link
Contributor

@kerchner using Firefox with JSONView

@justinlittman
Copy link
Contributor

That's because it is a line-oriented JSON file, which isn't valid JSON. Each of the lines is valid JSON.

@kerchner
Copy link
Member Author

kerchner commented Nov 3, 2016

👍

@Tanych
Copy link
Contributor

Tanych commented Nov 7, 2016

@kerchner could you send me the file that can't open?

@kerchner
Copy link
Member Author

kerchner commented Nov 7, 2016

sent via email

@Tanych
Copy link
Contributor

Tanych commented Nov 7, 2016

thanks!

@Tanych
Copy link
Contributor

Tanych commented Nov 8, 2016

The detail of the issue for openpyxl is here , currently, there is no any better way to handle such edge cases. A simple solution for this is to prefix the value with a single quote. But, there might another edge case such as -test,'1/0' etc.

@Tanych
Copy link
Contributor

Tanych commented Nov 10, 2016

For the openpyxl, if we set to the cell to TYPE_STRING, it also will check whether it stats with '=', if so, mark the cell as formula.

elif isinstance(value, STRING_TYPES):
            value = self.check_string(value)
            self.data_type = self.TYPE_STRING
            if len(value) > 1 and value.startswith("="):
                self.data_type = self.TYPE_FORMULA
            elif value in self.ERROR_CODES:
                self.data_type = self.TYPE_ERROR
            elif self.guess_types:
                value = self._infer_value(value)

Whether we should consider using xlsxwriter to write xlsx, it supports to disable convert string to formula.

I think the big difference between openpyxl and xlsxwriter is that openpyxl focuses on deal with xlsx files including loading, modify while xlsxwirter pays attention to write file as xlsx format.

https://xlsxwriter.readthedocs.io/workbook.html

@kerchner kerchner modified the milestones: 1.4, 1.3.1 Nov 16, 2016
@lwrubel lwrubel modified the milestones: 1.4, 1.3.1 Nov 21, 2016
@Tanych
Copy link
Contributor

Tanych commented Dec 6, 2016

For this issue, adding a single quote before and after the text field. The excel can consider the text as a regular string not the formula. It might modify the data, but can avoid the open failure.

@kerchner
Copy link
Member Author

Test after PR for #588 is merged

@Tanych
Copy link
Contributor

Tanych commented Dec 19, 2016

@kerchner you can retest the formula issue for twitter export when PR gwu-libraries/sfm-twitter-harvester#30 and gwu-libraries/sfm-utils#27 are merged.
It can guarantee no problem when exporting to xlsx but not csv.

@justinlittman
Copy link
Contributor

I tested and this works for xlsx, but not csv.

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

No branches or pull requests

5 participants