[Tutor] Handling missing fields in a csv file

2009-09-28 Thread Eduardo Vieira
Hello, I have a csv file, using the ";" as a delimiter. This file
contains addresses. My problem is that some fields are missing in some
rows and I would like to normalize the rows for a smoother import into
Excel, for example.
Here is an example. This is the header:
Company;Telephone;Address;Prov;PCode
While most of them have this header, some data would be like this:
Abc blaba;403-403-4545;MB ---> missing address, city, and postal code
Acme;123-403-4545;Winnipeg;MB;
I think a good solution would be to add delimiter to represent empty fields:
Abc blaba;403-403-4545;;;MB; -->missing address and postal code
Acme;123-403-4545;;Winnipeg;MB;

Fortunately the source has province names abbreviated (2 letters). I
could also take into account a postal code, maybe:
Given I have 2 simple functions:
isProvince()
isPostalCode():
How I would write to the proper fields once that was returned true?
Province has to go to row[3], and PCode to row[4] right?


Eduardo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Accessing windows from Linux build

2009-09-28 Thread Jesse L
I want to use a linux system to scan windows registries for a specific key.
I know there is the _winreg module, but it's only available on a windows
system.  Is there a module that will enable python to work cross platform?

Thank you
Jesse
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Accessing windows from Linux build

2009-09-28 Thread Alan Gauld

"Jesse L"  wrote

I want to use a linux system to scan windows registries for a specific 
key.


The basic requirement of reading a file on a Windows PC from
a Linux box is possible without much difficulty.


I know there is the _winreg module, but it's only available on a windows
system.  Is there a module that will enable python to work cross 
platform?


But you need a way to interpret that file and I'm not aware of any modules
for Linux that can do that. You best bet is probably to remotely run a
Windows command on the PC. But I'm not sure what command would
be best for that, I don't know of a command line registry scanner for
example.

It might be possible to do something with DCOM but I suspect you
would need a lot of configuration pre set on the Windows box to get it
to work - at least I really hope you need to do a lot of work otherwise
I'd be worried!

I assume you've already tried a Google search to see if somebody has
done it before?

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor