GRASS logo


m.csv.clean - Creates a cleaned-up copy a CSV files
Creates CSV files which are ready to used in GRASS GIS


miscellaneous, CSV, ASCII


m.csv.clean --help
m.csv.clean input=name separator=character output=name prefix=string [recognized_date=string[,string,...]] [clean_date=string] missing_names=string [cell_clean=string[,string,...]] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=name [required]
Input CSV file to clean up
Name of input file
separator=character [required]
Field separator
Special characters: pipe, comma, space, tab, newline
Default: comma
output=name [required]
Clean CSV output file
Name for output file
prefix=string [required]
Prefix for columns which don't start with a letter
Prefix itself must start with a letter of English alphabeth
Default: col_
Recognized date formats (e.g., %m/%d/%y)
For example, %m/%d/%Y,%m/%d/%y matches 7/30/2021 and 7/30/21
Format for new clean-up date
For example, %Y-%m-%d for 2021-07-30
Default: date_%Y-%m-%d
missing_names=string [required]
Names for the columns without a name in the header
If only one is provided, but more than one is need, underscore and column number is added
Default: column
Operations to apply to non-header cells in the body of the document
If only one is provided, but more than one is need, underscore and column number is added
Options: strip_whitespace, collapse_whitespace, date_format, none
Default: strip_whitespace,collapse_whitespace

Table of contents


m.csv.clean reads a CSV (Comma Separated Value) file, cleans it, and writes a new CSV file. The separator for CSV is comma (,) by default, but it can be set to any single character such as semicolon (;), pipe (|), or tabulator.


Originally, the name for this module was supposed to be m.csv.polish and the module was to be accompanied with module named m.csv.czech for checking the state of the CSV.


In GRASS GIS shell

The following would apply all the default fixes to the the file sampling_sites_raw.csv and output a cleaned file sampling_sites.csv:
m.csv.clean input=sampling_sites_raw.csv output=sampling_sites.csv

In any shell

The module is not using any information from the current location and mapset, so it is very easy to run it with an adhoc temporary location by executing a grass --exec command:
grass --tmp-location XY --exec m.csv.clean input=sampling_sites_raw.csv output=sampling_sites.csv



Vaclav Petras, NCSU Center for Geospatial Analytics


Available at: m.csv.clean source code (history)

Latest change: Thursday Feb 03 09:32:35 2022 in commit: f17c792f5de56c64ecfbe63ec315307872cf9d5c

Main index | Miscellaneous index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.3.3dev Reference Manual