Skip to content

Commit

Permalink
Updating README with a new usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-bunn committed Nov 3, 2017
1 parent fe8046a commit 6afb4fa
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,19 @@ Learn more by reading the `documentation <https://sandpaper.readthedocs.io/en/la

.. code:: python
from sandpaper import SandPaper
paper = SandPaper('my-sandpaper').strip( # strip whitespace from column comment
column_filter=r'comment'
).translate_text( # get group id from column group
column_filter=r'group',
from_regex=r'^group_(\d+)$',
to_format='{0}'
).translate_date( # normalize date from column date
column_filter=r'date',
from_formats=['%Y-%m-%d', '%m-%d'],
to_format='%c'
)
for result in paper.apply('~/random_data.{1..3}.{csv,xls{,x}}'):
# apply sandpaper rules to all files matching the brace expanded glob given
print(result)
from sandpaper import SandPaper
paper = SandPaper('my-sandpaper')\
.strip( # strip whitespace from column comment
column_filter=r'comment'
)\
.translate_text({ # get group id from column group
r'^group_(\d+)$': '{0}'
}, column_filter=r'group')\
.translate_date({ # normalize date from column date
'%Y-%m-%d': '%c',
'%m-%d': '%c'
}, column_filter=r'date')
# apply sandpaper rules to all files matching the brace expanded glob given
paper.apply('/home/you/source.csv', '/home/you/target.csv')

0 comments on commit 6afb4fa

Please sign in to comment.