From 90c1597cef44538b5ee7852973a50e8307f5aa8e Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Tue, 10 Feb 2009 02:43:19 +0000 Subject: [PATCH] fixed bug with items_to_csv and Excel. thanks Mat for the patch. See: http://groups.google.com/group/scrapy-developers/browse_thread/thread/9e2b80d226333011 --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40838 --- scrapy/trunk/scrapy/utils/misc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scrapy/trunk/scrapy/utils/misc.py b/scrapy/trunk/scrapy/utils/misc.py index 80a135e35..50f3876b3 100644 --- a/scrapy/trunk/scrapy/utils/misc.py +++ b/scrapy/trunk/scrapy/utils/misc.py @@ -140,7 +140,7 @@ def items_to_csv(file, items, delimiter=';', headers=None): return if isinstance(file, basestring): - file = open(file, 'a+') + file = open(file, 'ab+') csv_file = csv.writer(file, delimiter=delimiter, quoting=csv.QUOTE_ALL) header = headers or sorted([key for key in items[0].__dict__.keys() if not key.startswith('_')]) if not file.tell(): @@ -157,7 +157,8 @@ def items_to_csv(file, items, delimiter=';', headers=None): CAMELCASE_INVALID_CHARS = re.compile('[^a-zA-Z]') def string_camelcase(string): - """ Convert a word to it CamelCase version + """ Convert a word to its CamelCase version and remove invalid chars + >>> string_camelcase('lost-pound') LostPound