Cleaned picks.csv formatting with the csv library#11
Open
lennijusten wants to merge 1 commit intoAI4EPS:masterfrom
Open
Cleaned picks.csv formatting with the csv library#11lennijusten wants to merge 1 commit intoAI4EPS:masterfrom
lennijusten wants to merge 1 commit intoAI4EPS:masterfrom
Conversation
I described this issue in under AI4EPS#9 and here is the PR with the fix. The fix is a two-part solution. First, I open the picks.csv file as fclog with the csv library and write the header row. I then open picks.csv in the append mode and write the results to picks.csv batch by batch. The results are converted from arrays to lists (this removes the empty white spaces), and then written to the row in a list of results instead of a single string formatted with the results. This also fixes the new-line issue I had opened and resolved earlier. I have tried and tested the method and it works as hoped. Best, Lenni
Contributor
Author
|
Here is an excel copy of an example output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I described issue #9 a while ago and here is the PR with the fix. The fix is a two-part solution.
First, I open the
picks.csvfile in the writewmode with thecsv.writerfrom the csv library and write the header row. The writewmode will overwrite any existing file with the same filename.I then open picks.csv in the append
amode and write the results topicks.csvby looping through each batch. The results are converted from arrays to lists with thetolist()method which removes the excess white spaces. I then append the results to the csv with thewriterow()method by passing the results in list format. This automatically delimits the csv columns intofname,itp,tp_prob,its,ts_proband adresses any issues like overfull lines automatically (see issue #6).I have tried and tested the method and it works as hoped. When reading the csv files with
pandas, one should still note that thepandas.read_csv()method will default to reading all entries as strings. This is described fully in a stackoverflow post. An easy fix is using theliteral_evalmethod fromast.Best,
Lenni