-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
[loaders] improve fixed-width saver #2257
Conversation
2e000ab
to
d5d00a9
Compare
@@ -38,7 +38,7 @@ def columnize(rows): | |||
# collapse fields | |||
for i in allNonspaces: | |||
if i > prev+1: | |||
yield colstart, i | |||
yield colstart, prev+1 #2255 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be:
yield colstart, i-1 #2255
prev+1
collapses multiple spaces between columns.
i-1
assumes only a single space is the column separator, and keeps the remaining spaces as data.
For example, given the following fixed width data with three spaces between the columns:
column_1 column_2
one two
prev+1
would be saved as the following CSV. (Separating spaces are removed, but padding spaces are retained):
column_1,column_2
one ,two
i-1
would be saved as the following CSV. (One separating space is removed. All others are retained.):
column_1 ,column_2
one ,two
The current version of the code with prev+1
is my personal preference, but open to guidance if the i-1
version better matches the intent of 'fixed width'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, it must be i-1
rather than i
to avoid adding an extra space between the columns each round trip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I prefer prev+1
too. Thanks for the explanation.
I think this is ready for initial review. Let me know if you're happy with the suggested changes, and I'll update the tests accordingly. (They are currently broken due to these changes.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your attention on this, @daviewales! If you wouldn't mind updating the tests too, we'd much appreciate it.
d5d00a9
to
2502539
Compare
Don't add so many spaces between columns. Use the max width of the data, rather than the max width of the window.
2502539
to
bcd9a1f
Compare
Hey @daviewales! I went ahead and made the requested changes, and updated the tests. =) Thanks for taking care of this. |
Thanks @anjakefala, much appreciated! |
Don't add so many spaces between columns when saving.
Use the max width of the data, rather than the max width of the window when saving.
Don't include the separating space as data when loading. (Prevents extra space being added each round trip, as the saver also adds a single space between columns.)
Fixes #2255.