Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C csvkit
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 61
    • Issues 61
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wireservice
  • csvkit
  • Merge requests
  • !99

csvmap tool for mapping a python function to each cell in a column

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/ewheeler/master into master Aug 19, 2011
  • Overview 0
  • Commits 7
  • Pipelines 0
  • Changes 4

Created by: ewheeler

commit includes example data and example functions file

not sure if this is generally useful, but i find this handy for quick conversions or cleanups that fall outside of the realm of csvclean and are not so complicated that i'd want to write a one-off script (e.g., convert timestamp formatting or remove punctuation)

the idea is to create a python file with functions corresponding to column names. these functions are called for each cell in the corresponding column, and the result returned by the function replaces the original cell value. since column names can have spaces and non-ascii characters, csvmap includes a slugify function that will output ascii-only versions of column names that can be used as python method names.

calling csvmap with the -s flag will output these slugified versions

$ csvmap -s examples/csvmap_example_input.csv 
  1: timestamp_created
  2: companys_name

and then call csvmap with the -m option giving the path to the python file

$ csvmap -m examples/csvmap_example_mapfile.py examples/csvmap_example_input.csv
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ewheeler/master