-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Injecting mandatory FMTM fields into custom XLSForms #1722
Comments
This would make the XLSForms a whole lot more maintainable. Currently if we have say 10 categories = 10 XLSForms, we need to keep the extra fields we use in FMTM in sync for all of them. Ideally we have:
|
I just did a small assessment of package size between various XLS and XLSX parser libraries:
We should use |
I found that |
Oh no! That's a pain 😅 I considered Pandas but it's a huge library (200MB). Openpyxl is ancient now and unmaintained - but the It would mean we need to use it alongside xlrd to read Two other options:
|
Acknowledgement I have been a bit silly
If we ever need to revisit thisIf we ever want to remove pandas for any reason, we can consider
We would need to iterate through the from xlsxwriter import Workbook
from python_calamine import CalamineWorkbook
workbook = CalamineWorkbook.from_path("form.xlsx")
xlsx_data = workbook.get_sheet_by_name("survey").to_python()
# [
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ]
workbook = Workbook('combined.xlsx')
worksheet = workbook.add_worksheet("survey")
for row_index, row_data in enumerate(xlsx_data):
for column_index, column_data in enumerate(row_data):
# Get the column letter from column_index
column_letter = xxx
worksheet.write(f'{column_letter}{row_index}', column_data) |
Possible issue with translationsInteresting issue I just encountered! For the choice sheet we have a placeholder: The 1 values are for I'm raising this because it may cause issues with merging! Possible solution
Scenario 1:
Scenario 2:
Note In future we should translation our mandatory field questions into all available languages in ODK. |
For future reference,
My bad for missing that. Although it makes no difference now, as we are using higher level Pandas anyway. This may be useful for the future though, if one day we remove our reliance on Pandas in osm-fieldwork. |
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Option 1: append the fields in the XLSForm, either via pyxlsx or possibly via Pandas, prior to XLS --> XML.
Option 2: use the current XML parsing / manipulation method to inject all required params, after XLS --> XML.
Additional context
Note
See comment below. We should not use Pandas, but instead
python-calamine
.The text was updated successfully, but these errors were encountered: