Skip to content

Commit

Permalink
csvclean: Use stdin_out.csv instead of <stdin>_out.csv, closes #456
Browse files Browse the repository at this point in the history
  • Loading branch information
James McKinney committed Feb 9, 2016
1 parent ccbcc46 commit 50757a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -32,6 +32,7 @@ Fixes:
* in2csv correctly interprets --no-inference.
* in2csv again supports nested JSON objects (fixes regression).
* in2csv --format geojson will print a JSON object instead of `OrderedDict([(...)])`.
* csvclean with standard input works on Windows.
* csvgrep returns the input file's line numbers if the --linenumbers flag is set.
* csvgrep can match multiline values.
* csvsql correctly escapes `%` characters in SQL queries.
Expand Down
6 changes: 5 additions & 1 deletion csvkit/utilities/csvclean.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import sys
from os.path import splitext

import agate
Expand Down Expand Up @@ -34,7 +35,10 @@ def main(self):
if checker.joins:
self.output_file.write('%i rows would have been joined/reduced to %i rows after eliminating expected internal line breaks.\n' % (checker.rows_joined, checker.joins))
else:
base, ext = splitext(self.input_file.name)
if self.input_file == sys.stdin:
base = 'stdin' # "<stdin>_out.csv" is invalid on Windows
else:
base = splitext(self.input_file.name)[0]

with open('%s_out.csv' % base, 'w') as f:
clean_writer = agate.writer(f, **self.writer_kwargs)
Expand Down

0 comments on commit 50757a9

Please sign in to comment.