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

New functionality: --replace-headers #45

Merged
merged 5 commits into from
Feb 18, 2025
Merged

New functionality: --replace-headers #45

merged 5 commits into from
Feb 18, 2025

Conversation

esimpsons3ti
Copy link
Collaborator

This pull request will introduce the new feature, --replace-headers. This command line argument allows the user to change the names of columns via a user-provided text file. For example, the contents of this file can be:

pds:Product_Observational/pds:Identification_Area<1>/pds:logical_identifier<1>,LID
pds:Product_Observational/pds:Identification_Area<1>/pds:version_id<1>,VID
pds:Product_Observational/pds:Identification_Area<1>/pds:title<1>,Title

and it will replace the XPath with the given replacement string. This command can be applied to both index files and header files.

Fixes #21

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0de3011) to head (ffdb3c6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main       #45      +/-   ##
===========================================
+ Coverage   96.34%   100.00%   +3.65%     
===========================================
  Files           1         1              
  Lines         602       631      +29     
  Branches      124       132       +8     
===========================================
+ Hits          580       631      +51     
+ Misses         17         0      -17     
+ Partials        5         0       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@rfrenchseti rfrenchseti left a comment

Choose a reason for hiding this comment

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

This seems to do what I was hoping for. One small thing is if you have a blank line in your mapping file, it reports it as an error. It would be nice to skip over blank lines so people can organize their field renaming with gaps between them. As an added feature it would be nice to allow comment lines starting with "#" that are ignored. This already works for limit-xpaths files, probably just because there will never be an XML tag that starts with "#" so it never matches.

Replaces column names in a DataFrame or list of XPaths using a mapping file.

This function determines the output depending on whether an index file or a
headers file is being generated. If an index is True, it will output a new DataFrame
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't say "an index".

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also really df and index are redundant fields. You can't specify index=True without also specifying df. I would delete the index argument entirely, and just check to see if df is None. However, at that point, df and xpaths are redundant - you must specify one or the other but not both. So really you just want a single argument called something like df_or_xpaths. Then in the code you can say if isinstance(df_or_xpaths, pandas.DataFrame):

@esimpsons3ti esimpsons3ti merged commit e3633dc into main Feb 18, 2025
18 checks passed
@esimpsons3ti esimpsons3ti deleted the es-new_features branch February 18, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File to allow renaming of headers
2 participants