473,769 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

better csv modules and where have object-craft gone?

Hi

I have been using object crafts csv module for quite a few projects,
mainly because I found the csv in python in it's current incarnation
is funtionally inferior to object crafts. The object craft module
for instance allowed you build up csv gradually (ie field at a time
rather the python csv module where the writer does the work a record at
a time) which isn't always the way I would like to work,
also I have always had encoding problems (specifcally it doesn't
support unicode as per the docs) everytime I used the python
module where as the object craft one always worked out of the box.

Only problem is object craft seemed to have disappeared off the face
of the net (ie I can't even resolve their name in DNS).

Which is a pity as I don't have a current copy for 2.3 (windows)
of their csv module.

Does anyone have a copy of the object-craft csv module, or does
anyone know where they have relocated ?

It is a pity if they have disappeared.

Rgds

Tim
Jul 18 '05 #1
3 1580
Oops ignore my comment on the DNS front for object craft,
seems my ISP's DNS just wasn't resolving it earlier today
seems to have popped back up on the radar now though

T

Tim Hoffman wrote:
Hi

I have been using object crafts csv module for quite a few projects,
mainly because I found the csv in python in it's current incarnation
is funtionally inferior to object crafts. The object craft module
for instance allowed you build up csv gradually (ie field at a time
rather the python csv module where the writer does the work a record at
a time) which isn't always the way I would like to work,
also I have always had encoding problems (specifcally it doesn't
support unicode as per the docs) everytime I used the python
module where as the object craft one always worked out of the box.

Only problem is object craft seemed to have disappeared off the face
of the net (ie I can't even resolve their name in DNS).

Which is a pity as I don't have a current copy for 2.3 (windows)
of their csv module.

Does anyone have a copy of the object-craft csv module, or does
anyone know where they have relocated ?

It is a pity if they have disappeared.

Rgds

Tim

Jul 18 '05 #2

Tim> I have been using object crafts csv module for quite a few
Tim> projects, mainly because I found the csv in python in it's current
Tim> incarnation is funtionally inferior to object crafts. The object
Tim> craft module for instance allowed you build up csv gradually (ie
Tim> field at a time rather the python csv module where the writer does
Tim> the work a record at a time) which isn't always the way I would
Tim> like to work, also I have always had encoding problems (specifcally
Tim> it doesn't support unicode as per the docs) everytime I used the
Tim> python module where as the object craft one always worked out of
Tim> the box.

I guess beauty is in the eye of the beholder. The Object Craft folks were
key authors of what's in the Python distribution. If you want to write a
field at a time, you should be able to subclass the csv.writer class and add
writefield() and commit() methods. The first appends to an internal list.
The second calls writerow() and clears the list. Something like this
(untested) code might work:

class FieldWriter(csv .writer):
def __init__(self, *args, **kwds):
csv.writer.__in it__(self, *args, **kwds)
self.temp = []

def writefield(self , val):
self.temp.appen d(val)

def commit(self):
self.writerow(s elf.temp)
self.temp = []

(Be careful. You'll lose partial results if you don't clean up in a __del__
method.)

As for lack of Unicode support that's a known issue. I suppose it hasn't
been high enough on anyone's list of itches to have attracted any scratching
yet. Still, you might be able to get most of the way there with a subclass:

class UnicodeWriter(c sv.writer):
def __init__(self, *args, **kwds):
self.encoding = kwds.get('encod ing', 'utf-8')
if 'encoding' in kwds: del kwds['encoding']
csv.writer.__in it__(self, *args, **kwds)

def writerow(self, row):
for (i,f) in enumerate(row):
if isinstance(f, unicode):
row[i] = f.encode(self.e ncoding)

I'm almost certain that reading data in multibyte encodings won't work
though, as the low-level reader is byte-oriented instead of
character-oriented. Patches are welcome to resolve that deficiency.

Skip

Jul 18 '05 #3
Skip Montanaro wrote:
Tim> I have been using object crafts csv module for quite a few
Tim> projects, mainly because I found the csv in python in it's current
Tim> incarnation is funtionally inferior to object crafts. The object
Tim> craft module for instance allowed you build up csv gradually (ie
Tim> field at a time rather the python csv module where the writer does
Tim> the work a record at a time) which isn't always the way I would
Tim> like to work, also I have always had encoding problems (specifcally
Tim> it doesn't support unicode as per the docs) everytime I used the
Tim> python module where as the object craft one always worked out of
Tim> the box. As for lack of Unicode support that's a known issue. I suppose it hasn't
been high enough on anyone's list of itches to have attracted any scratching
yet. Still, you might be able to get most of the way there with a subclass:

class UnicodeWriter(c sv.writer):
def __init__(self, *args, **kwds):
self.encoding = kwds.get('encod ing', 'utf-8')
if 'encoding' in kwds: del kwds['encoding']
csv.writer.__in it__(self, *args, **kwds)

def writerow(self, row):
for (i,f) in enumerate(row):
if isinstance(f, unicode):
row[i] = f.encode(self.e ncoding)

I'm almost certain that reading data in multibyte encodings won't work
though, as the low-level reader is byte-oriented instead of
character-oriented. Patches are welcome to resolve that deficiency.


Aha! so this is why my csv2po converter is getting strange encodings out...
What I'd really like to write/have is a pure Python implementation of
the csv module. Presumably this would
1) Make Unicode trivial
2) Be slower
Anyhow it would be nice...

David
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8221
by: George Adams | last post by:
I like the idea of compiling DSO modules for Apache. It allows me to turn on or off things we may or may not need at a given time (like mod_ssl, mod_auth_mysql, mod_auth_ldap, etc.) and also allows me to compile in new versions of modules without having to rebuild Apache from scratch. Now, when I build PHP, I tend to put in a lot of things. Like:
220
19152
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
1
1635
by: KN | last post by:
Hello, I'm new to this list, and I have an important question at the beginning. There is a matter that concerns me - it's the globales implementation. I've read nearly everything I found about this and about problems people were having with using it. And now I'd like to ask here, because it seems to be more than globales() matter, but an object-programming
47
2620
by: Will Stuyvesant | last post by:
Hello all, So Zope still lives, yay. Well, I like that they use Python. <rant> What amazed me is they write that they "added types to the variables and hope that it will be added to the Python project too". Really. ROFL.
8
1642
by: Rob Snyder | last post by:
Greetings - I have a situation where I need to be able to have a Python function that will take all the modules in a given directory and find all the classes defined in these modules by name. Ultimately, I would need to loop through all of these, instantiating each of the classes in turn and calling a pre-known method of each. Finding the name of each module is not a problem, but loading the classes out the module once I know the name...
4
2157
by: Chuck Ritzke | last post by:
I keep asking myself this question as I write class modules. What's the best/smartest/most efficient way to send a large object back and forth to a class module? For example, say I have a data access module that creates a large disconnected dataset from a database. I want to pass that dataset back to the calling program. And then perhaps I want to send that dataset to another class module. At first it seems that the "object oriented"...
9
2736
by: Emmanuel Charruau | last post by:
Hi, I am looking for a class or any information which would allow me to make communicate mini-module in c++. I have been looking on the net for some examples of such implementation, but I did not find any good one. This is why I am asking here if some of you know where to find some information on the internet about such implementation.
4
3105
by: Steven T. Hatton | last post by:
You can scroll down to the last line of this post in order to find the question I really want to discuss. I was just pondering the competing applicability of C vs. C++ in certain problem domains. Then I saw this as Stroustrup's FAQ of the day: http://www.research.att.com/~bs/bs_faq.html#C-is-better Q:"C is better than C++ for small projects, right?" A:"Not in my opinion. I never saw a project for which C was better than C++
6
1409
by: Steven W. Orr | last post by:
Given the following code: (I hope it's as simple as possible) :-) #! /usr/bin/python import new class BASE: def __init__( self ): print 'Hello from BASE init' def m1( self ): print 'M1 Base: Self = ', self def m1replace( self ):
1
1171
by: stef mientki | last post by:
hello, I've a program where users can make modules, by just dumping them in a certain directory, then they will dynamically link into the program if needed. One of the communication channels I use, is a general global file, which should be imported by all user modules. One of the things a user should be able to do is to create " global
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.