473,583 Members | 3,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Can Python fix vcard files?

DotanCan Python go through a directory of files and replace each
Dotaninstance of "newline-space" with nothing?

Sure. Something like (*completely* untested, so caveat emptor):

import glob
import os

for f in glob.glob('*.vc f'):
# corrupt data
uncooked = open(f, 'rb').read()
# fix it
cooked = uncooked.replac e('\n ', '')
# backup original file for safety
os.rename(f, '%s.orig' % f)
# and save it
open(f, 'wb').write(coo ked)

Skip Montanaro - sk**@pobox.com - http://www.webfast.com/~skip/
Oct 14 '08 #1
0 850

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

Similar topics

by: Michael McGarry | last post by:
Hi, I am just starting to use Python. Does Python have all the regular expression features of Perl? Is Python missing any features available in Perl? Thanks, Michael
by: Ed | last post by:
What's the easiest way of developing an address book using ASP that is compatible with vCard? I'd like to be able to do this without 3rd party components. Thanks.
by: scott | last post by:
Anyone have a link to syntax that could create an outlook vcard file format? all examples i find are for doing it inside outlook with .net. i'm just looking for an ASP solution.
by: Jason Karns | last post by:
Does anyone know of any stylesheets out that are already built to transform the RDF vCard format (XML) to regular vCard file format (.vcf)? I've searched google for a while now and haven't found anything. -Jason
by: localhost | last post by:
Looking for some sample code to emit a vcard (for Outlook) directly to a web browser after clicking on a button. Thanks.
by: yochessyo | last post by:
Hi, Is there a way in VB.net to create or manipulate vcard? Thank you for your help.
by: R Wood | last post by:
Greetings - A recent Perl experiment hasn't turned out so well, which has piqued my interest in Python. The project is this: take a Vcard file exported from Apple's Addressbook and use a language that is good at parsing text to convert it into a mutt alias file. There are better ways to use Mutt with Mac's addressbook, but I want to be...
by: eloi-ribeiro.blogspot.com | last post by:
Hi everyone, I would like to use a python script to export (save as...) all my contacts in Evolution to VCard format (.vcf). I am a beginner so I don't knock how to use evolution-python module. The second part of the script would be to make inserts to a database, at these second part, I think I can menage my self. Thanks in advance and...
by: Dotan Cohen | last post by:
KDE's Kontact PIM breaks quoted-printable vcard files because it linebreaks in the middle of a word. Take this text for example: NOTE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=A9=D7=95=D7=A8=D7=94 =D7=A 8=D7=90=D7=A9=D7=95=D7=A0=D7=94.\n=D7=94=D7=A9=D7=95=D7=A8=D7=94 =D7=94=D7= A9=D7=A0=D7=99=D7=94 =D7=9B=D7=\n The whole thing should be...
by: Tommy Nordgren | last post by:
On Oct 14, 2008, at 3:23 AM, Dotan Cohen wrote: Sure! all the bytes in multibyte UTF-8 characters are above 128 in value. Thus, they won't be replaced. ---------------------------------- Skinheads are so tired of immigration, that they are going to move to a country that don't accept immigrants!
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...
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. ...
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...
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...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.