Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

fixed bug with items_to_csv and Excel. thanks Mat for the patch. See:

Pablo Hoffman90c1597cef44
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