Cleaned picks.csv formatting with the csv library #11
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.csv
file in the writew
mode with thecsv.writer
from the csv library and write the header row. The writew
mode will overwrite any existing file with the same filename.I then open picks.csv in the append
a
mode and write the results topicks.csv
by 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_prob
and 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_eval
method fromast
.Best,
Lenni