Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: JoeGermuska/csvkit
...
head fork: JoeGermuska/csvkit
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 3 contributors
Commits on May 12, 2012
@msabramo msabramo Fix for the fact that some versions of the csv module (apparently
including some bundled with pypy) misspell the word "larger" as
"larget". This fixes one pypy test failure mentioned in GH-165.
1ad45af
Commits on May 15, 2012
@onyxfish onyxfish Merge pull request #170 from msabramo/fix-pypy-larget-test-failure
Fix for the fact that some versions of the csv module (apparently
642a2c7
@onyxfish onyxfish Add Marc Abramowitz to AUTHORS. ad4cd7a
Commits on May 16, 2012
@onyxfish onyxfish Add DBF support to docs. Closes #167. b79e007
Commits on Jun 02, 2012
@JoeGermuska Merge branch 'master' of https://github.com/onyxfish/csvkit 1e71768
@JoeGermuska make 'encoding' a kwarg for FixedWidthReader, so that python code can…
… handle non-default encodings, not just in2csv
0173dfc
View
1  AUTHORS
@@ -17,3 +17,4 @@ The following individuals have contributed code to csvkit:
* Anton Ian Sipos
* Gregory Temchenko
* Kevin Schaul
+* Marc Abramowitz
View
14 csvkit/convert/fixed.py
@@ -21,12 +21,14 @@ def fixed2csv(f, schema, output=None, **kwargs):
if not streaming:
output = StringIO()
- if 'encoding' in kwargs and kwargs['encoding']:
- f = iterdecode(f, kwargs['encoding'])
-
+ try:
+ encoding = kwargs['encoding']
+ except KeyError:
+ encoding = None
+
writer = CSVKitWriter(output)
- reader = FixedWidthReader(f, schema)
+ reader = FixedWidthReader(f, schema, encoding=encoding)
writer.writerows(reader)
if not streaming:
@@ -43,7 +45,9 @@ class FixedWidthReader(object):
The schema_file should be in CSV format with a header row which has columns 'column', 'start', and 'length'. (Other columns will be ignored.) Values in the 'start' column are assumed to be "zero-based" unless the first value is "1" in which case all values are assumed to be "one-based."
"""
- def __init__(self, f, schema):
+ def __init__(self, f, schema, encoding=None):
+ if encoding is not None:
+ f = iterdecode(f, encoding)
self.file = f
self.parser = FixedWidthRowParser(schema)
self.header = True
View
3  csvkit/unicsv.py
@@ -6,6 +6,7 @@
import codecs
import csv
+import fnmatch
from cStringIO import StringIO
from csvkit.exceptions import FieldSizeLimitError
@@ -40,7 +41,7 @@ def next(self):
row = self.reader.next()
except csv.Error, e:
# Terrible way to test for this exception, but there is no subclass
- if 'field larger than field limit' in str(e):
+ if fnmatch.fnmatch(str(e), 'field large[rt] than field limit *'):
raise FieldSizeLimitError(csv.field_size_limit())
else:
raise e
View
6 docs/scripts/in2csv.rst
@@ -31,7 +31,7 @@ The header line is required though the columns may be in any order::
-f FORMAT, --format FORMAT
The format of the input file. If not specified will be
inferred from the filename. Supported formats: csv,
- fixed, json, xls, xlsx.
+ dbf, fixed, json, xls, xlsx.
-s SCHEMA, --schema SCHEMA
Specifies a CSV-formatted schema file for converting
fixed-width files. See documentation for details.
@@ -68,3 +68,7 @@ Fetch csvkit's open issues from the Github API, convert the JSON response into a
$ curl http://github.com/api/v2/json/issues/list/onyxfish/csvkit/open | in2csv -v -k issues > issues.csv
+Convert a DBase DBF file to an equivalent CSV::
+
+ $ in2csv examples/testdbf.dbf > testdbf_converted.csv
+
View
4 requirements.txt
@@ -1,5 +1,5 @@
argparse==1.2.1
-nose==1.0.0
+nose==1.1.2
xlrd==0.7.1
python-dateutil==1.5
sqlalchemy==0.6.6
@@ -7,4 +7,4 @@ sphinx==1.0.7
coverage==3.5.1b1
openpyxl==1.5.7
tox==1.3
-dbf==0.90.004
+dbf==0.93.000
View
2  setup.py
@@ -50,5 +50,5 @@
'python-dateutil==1.5',
'sqlalchemy==0.6.6',
'openpyxl==1.5.7',
- 'dbf==0.90.004']
+ 'dbf==0.93.000']
)

No commit comments for this range

Something went wrong with that request. Please try again.