aboutsummaryrefslogtreecommitdiff
path: root/gn3/csvcmp.py
AgeCommit message (Collapse)Author
2022-05-06Fix linting and typing errorsFrederick Muriuki Muriithi
2022-04-29Replace whole header with the longest one, instead of just thezsloan
non-CaseAttribute headers (before this caused issues if someone was adding case attributes to a file that already contained some case attributes)
2022-04-29Get max string length instead when comparing headerszsloan
Apparently max(string1, string2) in Python gets the strong that is highest alphabetically, but I'm pretty sure this line was intenteded to get the header with the most items (which this commit doesn't fully address; you could still end up with a situation where some case attributes were removed while others were added, though that should be rare)
2022-04-12Delete "get_allowable_sampledata_headers"BonfaceKilz
* gn3/csvcmp.py (get_allowable_sampledata_headers): Delete it. * tests/unit/test_csvcmp.py: Remove "get_allowable_sampledata_headers" import. (test_get_allowable_csv_headers): Delete it.
2022-04-07Fix mypy errorBonfaceKilz
2022-04-07Add method for parsing a csv header from uploaded sample-data fileBonfaceKilz
* gn3/csvcmp.py (parse_csv_column): New function. * tests/unit/test_csvcmp.py: Test case for the above.
2022-04-01Run python-black in fileBonfaceKilz
* gn3/csvcmp.py: Run "black -l 79 ..." * tests/unit/db/test_sample_data.py: Ditto. * tests/unit/test_csvcmp.py: Ditto.
2022-03-18Clean all csv fields before diffingBonfaceKilz
There was a subtle bug where "csvdiff" generated an error related to "different column headings" caused something akin to diffing: "a, b \n, ..." with "a, b\n, ...". * gn3/csvcmp.py (csv_diff): Clean csv texts before any diffing. * tests/unit/test_csvcmp.py (test_csv_diff_same_columns): Modify test case to capture aforementioned bug.
2022-03-18Create new function for cleaning individual fields in csv textBonfaceKilz
* gn3/csvcmp.py (clean_csv_text): New function. * tests/unit/test_csvcmp.py: Import "csv_text". (test_clean_csv_text): Test case for the above.
2022-03-14Only loop through the diff's modifications if it existsBonfaceKilz
2022-03-14Given a csv text and permissible headers, extract invalid headersBonfaceKilz
* gn3/csvcmp.py (extract_invalid_csv_headers): New function. * tests/unit/test_csvcmp.py: Import "extract_invalid_csv_headers". (test_extract_invalid_csv_headers_with_some_wrong_headers): Test case for the above.
2022-03-14Get all permissible column dataBonfaceKilz
* gn3/csvcmp.py: Import "Any" and "List". (get_allowable_sampledata_headers): New function. * tests/unit/test_csvcmp: Import "get_allowable_sampledata_headers". (test_get_allowable_csv_headers): Test case for the above.
2022-03-12Fix mypy issuesBonfaceKilz
2022-03-12Fix pylint issuesBonfaceKilz
2022-03-12Compose csv-diff command within single quotesBonfaceKilz
* gn3/csvcmp.py (csv_diff): Use single quotes. There was a change in 6d39c92 that broke this.
2022-03-12Delete noisy "print" statementBonfaceKilz
2022-03-12Fill in empty values in csv text with: "x"BonfaceKilz
* gn3/csvcmp.py (fill_csv): Update this function to allow empty lists to be filled with the default value(set in the args). * tests/unit/test_csvcmp.py (test_fill_csv): Update test to capture above.
2022-03-12Extract a strain name given a csv string and it's headerBonfaceKilz
* gn3/csvcmp.py (extract_strain_name): New function. * gn3/db/sample_data (delete_sample_data): Use the aforementioned function. (insert_sample_data): Ditto. * tests/unit/test_csvcmp: Test cases for above.
2022-03-12Don't add extra key "Column" to dict if there are no changesBonfaceKilz
gn3/csvcmp.py (csv_diff): If the diff is empty, don't add an extra key "Column" to the dictionary. tests/unit/test_csvcmp (test_csv_diff_only_column_change): Add test-case for the above.
2022-03-12Fill CSV text if there are non-even rowsBonfaceKilz
Should you try to run `csvdiff` against 2 csv files with either file having a non-even columns, there will be an error. As such, the csv files need to be "filled" before running `csvdiff`. * gn3/csvcmp (csv_diff): For non-even rows in the csv files, fill the csv rows.
2022-03-12Create new method for filling csv with a default valueBonfaceKilz
* gn3/csvcmp.py (fill_csv): Given a csv text with uneven or incomplete fields whole length are less than width, fill them with a value which defaults to "x". * tests/unit/test_csvcmp.py (test_fill_csv): Test cases for the above.
2022-03-12Replace "all" with "and"BonfaceKilz
* gn3/csvcmp.py (remove_insignificant_edits): "all" evaluates all elements and throws an error if when `abs(float(x) - float(y)) < epsilon` is processed. Use "and" instead because of it's short-circuiting behaviour.
2022-03-12Store columns in the output dictBonfaceKilz
When inserting, deleting, or editing case-attributes, we need the column headers in order to be able to know identify the attribute of interest. * gn3/csvcmp.py (csv_diff): Add extra "Column" key in returned dict.
2022-03-12Add methods for working with csv dataBonfaceKilz
gn3/csvcmp.py: New file (create_dirs_if_not_exists): From a list of dirs, create them if they don't exist. (remove_insignificant_edits): Given a dict with a "Modification" key, remove edits with "delta < ε". (csv_diff): Generate a csv_diff using the "csvdiff" tool packaged in guix. tests/unit/test_csvcmp.py: Add some tests for "gn3/csvcmp.py"