ImperialCollegeLondon / pycsvy

Python reader/writer for CSV files with YAML header information
BSD 3-Clause "New" or "Revised" License
7 stars 8 forks source link

add `basic_read` function for simpler CSVY parsing #131

Closed Kaos599 closed 3 weeks ago

Kaos599 commented 3 weeks ago

The new basic_read function provides a more user-friendly way to parse CSVY files by returning a dictionary format that separates column headers and data. This format includes:

The basic_read function leverages read_header to extract YAML metadata and comment markers, followed by a CSV reader to populate data rows. This method supports a cleaner, native Python structure without dependencies on external libraries for basic file reading, improving accessibility for developers without numpy, pandas, or polars.

Tested Locally

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.38%. Comparing base (05e324e) to head (8af61ec). Report is 120 commits behind head on develop.

Files with missing lines Patch % Lines
csvy/readers.py 93.75% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #131 +/- ## =========================================== - Coverage 93.58% 93.38% -0.21% =========================================== Files 3 4 +1 Lines 156 272 +116 =========================================== + Hits 146 254 +108 - Misses 10 18 +8 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Kaos599 commented 3 weeks ago

@AdrianDAlessandro All Checks have been passed. I am sorry for not checking the pre-commit check earlier.

The new function is 90% the same as read_to_list, it would be better to call that function instead of re-write the same stuff.

To address that i have modified basic_read by reusing read_to_list and then formatting the output.

There should be a test added into tests/test_read.py for this new function

I have added test as tests/test_basic_read.py & a csvy file as tests/test_basic_read.csvy

Also, can you assign this PR with Hacktoberfest label. Thank you

Kaos599 commented 3 weeks ago

Having lint issues, will close this PR and and send a fresh one again