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

Add identifier_case option to convert camelCase to snake_case and update documentation #486

Merged

Conversation

OmarAI2003
Copy link
Contributor

  • Added camel_to_snake function to convert camelCase keys and column headers to snake_case for consistency
  • Updated key and column name handling in convert_to_csv_or_tsv and convert_to_json functions

Contributor checklist


Description

This PR refactors the Scribe-Data export functionality to ensure consistency in key naming conventions by converting all camelCase JSON keys, CSV/TSV column headers, and SQLite columns to snake_case. This change improves alignment with common conventions for JSON and database formatting.

Changes Made

  • Introduced a camel_to_snake helper function to convert camelCase strings to snake_case.
  • Updated the convert_to_json function to apply the new naming convention to JSON keys.
  • Modified the convert_to_csv_or_tsv function to apply snake_case conversion to column headers in CSV/TSV exports.
  • Converted column names in the create_table function to snake_case when creating SQLite tables.

Related issue

- Added camel_to_snake function to convert camelCase keys and column headers to snake_case for consistency
- Updated key and column name handling in convert_to_csv_or_tsv and convert_to_json functions
- Updated the create_table function to convert column names from camelCase to snake_case before creating the SQLite table.
- Included a new import for the camel_to_snake function to handle the conversion.
Copy link

github-actions bot commented Oct 25, 2024

Thank you for the pull request!

The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Data rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you!

Maintainer checklist

  • The linting and formatting workflow within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@andrewtavis andrewtavis self-requested a review October 25, 2024 20:40
@andrewtavis andrewtavis added the hacktoberfest-accepted Accepted as a part of Hacktoberfest label Oct 25, 2024
- Added the camel_to_snake function to the utils.py file to avoid circular import issues.
- Updated the import statements in data_to_sqlite.py and convert.py to reference the new location of the function.
- Verified that all tests pass successfully after the changes.
@OmarAI2003
Copy link
Contributor Author

Should I close this now?

@andrewtavis
Copy link
Member

I still need to review and merge it into the project, @OmarAI2003 :)

@andrewtavis
Copy link
Member

Something that came up in the last sync for this @OmarAI2003 was that the general thought is that some users will want camelCase as well, and that that might be a better default as the data here is more for apps rather than analysis. Could we switch this over to an argument for get and convert whereby the conversion happens only if someone passes --identifier-case snake, where the default would be camel that they wouldn't need to pass an arg for?

@OmarAI2003 OmarAI2003 force-pushed the convert-CamelCase-to-snake_case branch from 85af6f2 to 1f0313f Compare November 11, 2024 15:52
@OmarAI2003
Copy link
Contributor Author

OmarAI2003 commented Nov 11, 2024

  • I added the --identifier-case argument to the convert command, with "camel" as the default for compatibility with applications.
  • Updated the documentation to include the new identifier-case option.

a1
a2

@OmarAI2003 OmarAI2003 force-pushed the convert-CamelCase-to-snake_case branch from 05bca42 to caaebac Compare November 11, 2024 18:23
Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really some great work here, @OmarAI2003 😊 Thanks so much for the fix post the discussion in the sync! Sorry that the directions weren't as clear from the start, but also great that we have this better solution.

@andrewtavis andrewtavis merged commit a0e0692 into scribe-org:main Nov 11, 2024
8 checks passed
@OmarAI2003 OmarAI2003 deleted the convert-CamelCase-to-snake_case branch November 12, 2024 10:41
@OmarAI2003 OmarAI2003 changed the title Convert camel case to snake case Add identifier_case option to convert camelCase to snake_case and update documentation Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted as a part of Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants