Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/onyxfish/csvkit
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGermuska committed Oct 14, 2011
2 parents 02fce04 + 666aa36 commit ddc7b26
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion csvkit/cli.py
Expand Up @@ -225,14 +225,16 @@ def parse_column_identifiers(ids, column_names):

for c in ids.split(','):
c = c.strip()

try:
columns.append(match_column_identifier(column_names, c))
except ColumnIdentifierError:
if ':' in c:
a,b = c.split(':',1)
elif '-' in c:
a,b = c.split('-',1)
else: raise
else:
raise

try:
if a:
Expand Down
2 changes: 1 addition & 1 deletion csvkit/utilities/in2csv.py
Expand Up @@ -35,7 +35,7 @@ def main(self):
elif self.args.key:
format = 'json'
else:
if self.args.file == '<stdin>':
if self.args.file == sys.stdin:
self.argparser.error('You must specify a format when providing data via STDIN (pipe).')

format = convert.guess_format(self.args.file)
Expand Down
12 changes: 10 additions & 2 deletions tests/test_utilities/test_in2csv.py
@@ -1,9 +1,17 @@
#!/usr/bin/env python

import unittest
import StringIO

from csvkit.utilities.in2csv import In2CSV

class TestIn2CSV(unittest.TestCase):
pass

def test_convert_xls(self):
args = ['-f', 'xls', 'examples/test.xls']
output_file = StringIO.StringIO()

utility = In2CSV(args, output_file)
utility.main()

target_output = open('examples/testxls_converted.csv', 'r').read()
self.assertEqual(output_file.getvalue(), target_output)

0 comments on commit ddc7b26

Please sign in to comment.