Sponsored Content
Top Forums Shell Programming and Scripting Fixing corrupted vcard files. Post 302247221 by dotancohen on Wednesday 15th of October 2008 07:49:08 AM
Old 10-15-2008
Thanks. I'm going through the docs as we speak. Perl is _complicated_! That does not seem to be my own opinion, either. Googling some example leads me to lots of frustrated people!

In any case, I probably should have posted the entire vcard file. Here it is, along with the results of the code:
Code:
hardy2@hardy2-laptop:~/test$ cat test.vcf
BEGIN:VCARD
FN:First Last
N:Last;First;;;
NOTE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:First Line.\nThe Second Line i
 s long so that it will wrap. Long\, long\, and wrapping!=\n\nThird Line.\n
UID:frh74xvYZ9
VERSION:2.1
END:VCARD

BEGIN:VCARD
FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=90=D7=90=D7=A4=D7=A8=D7=98=D
 7=99 =D7=9E=D7=A9=D7=A4=D7=97=D7=94
N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=9E=D7=A9=D7=A4=D7=97=D7=94;=D
 7=90=D7=90=D7=A4=D7=A8=D7=98=D7=99;;;
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=A9=D7=95=D7=A8=D7=94 =D7=A9=D7=A0=D7=
 99=D7=94 =D7=94=D7=99=D7=90 =D7=\n=90=D7=A8=D7=95=D7=9B=D7=94\, =D7=9B=D7=9
 3=D7=99 =D7=A9=D7=A0=D7=A8=D7=90=\n =D7=90=D7=95=D7=AA=D7=94 =D7=92=D7=95=D
 7=9C=D7=A9=D7=AA. =D7=90=D7=A8=D7=\n=95=D7=9B=D7=94\, =D7=90=D7=A8=D7=95=D7
 =9B=D7=94\, =D7=95=D7=92=D7=95=D7=9C=\n=D7=A9=D7=AA!\n=D7=A9=D7=95=D7=A8=D7
 =94 =D7=A9=D7=9C=D7=99=D7=A9=D7=99=D7=AA.\n
UID:KqbQKbfBaF
VERSION:2.1
END:VCARD

hardy2@hardy2-laptop:~/test$ perl -pi.bak -e 'BEGIN { $/=""; } s/\n //gm' *.vcf
hardy2@hardy2-laptop:~/test$ cat test.vcf
BEGIN:VCARD
FN:First Last
N:Last;First;;;
s long so that it will wrap. Long\, long\, and wrapping!=\n\nThird Line.\ni
UID:frh74xvYZ9
VERSION:2.1
END:VCARD

BEGIN:VCARD
7=99 =D7=9E=D7=A9=D7=A4=D7=97=D7=94INTABLE:=D7=90=D7=90=D7=A4=D7=A8=D7=98=D
7=90=D7=90=D7=A4=D7=A8=D7=98=D7=99;;;ABLE:=D7=9E=D7=A9=D7=A4=D7=97=D7=94;=D
=94 =D7=A9=D7=9C=D7=99=D7=A9=D7=99=D7=AA.\nA9=D7=AA!\n=D7=A9=D7=95=D7=A8=D7
UID:KqbQKbfBaF
VERSION:2.1
END:VCARD

hardy2@hardy2-laptop:~/test$

As can be easily seen, the lines still wrap, and worse, critical parts of the file are destroyed. I have been playing around with the line of code, but it is slow going and I could really use a hand with this. I do appreciate your patience and willingness to teach a noob.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Corrupted files from Windows to Unix Sco

I downloaded some applications from CD on a windows2000 PC to a Unix Sco machine using the WS-FTP program. When I tried to run the applications on the Unix machines I got an error. The files must have been corrupted in the process of transferring files from a Windows 2000 to a Unix Sco... (9 Replies)
Discussion started by: BAM
9 Replies

2. UNIX for Dummies Questions & Answers

Extracting files from corrupted tape

I've got a backuptape in cpio format that was accidentally overwritten with a very small batch file. As I assume that the cpio header has been overwritten, I cannot extract files from the backup in the conventional manner: ( cpio -itv </dev/rct0 cpio: this is not a cpio file, bad header) ... (0 Replies)
Discussion started by: mart4179
0 Replies

3. Linux

fixing with sed

I am trying to replace the value of $f3 but its not working . I don't know what I am missing here . cat dim_copy.20080516.sql | grep -i "create view" | grep -v OPSDM002 | while read f1 f2 f3 f4 f5 f6 f7 f8 f9 do echo " $f3 " sed -e... (13 Replies)
Discussion started by: capri_drm
13 Replies

4. Solaris

PAM login library files corrupted, have ILOM, can I get root?

I was installing sfw sudo and its dependencies (libiconv, libintl, libgcc)on Solaris 10, running on an x86 x4200 and I corrupted some PAM library files. It's a standard Solaris 10 base install, with some added software & libraries from a vendor. I am on console trying to get root access back,... (1 Reply)
Discussion started by: Mariognarly
1 Replies

5. HP-UX

WinRAR files are corrupted after FTP

In my Windows 2003 server machine I have a winrar or winzip file that i around 3GB. This zip/rar file is ftped to a unix mahine (HPUX) . FTP is successful. But when it get this file to check if its has been ftped correctly, the file is corrupted. Is there something wrong that i am doing while... (4 Replies)
Discussion started by: maroli
4 Replies

6. Shell Programming and Scripting

Help fixing awk code to print values from 2 files

Hi everyone, Please help on this: I have file1: <file title="Title 1 and 2"> <report> <title>Title 1</title> <number>No. 1234</number> <address>Address 1</address> <date>October 07, 2009</date> <description>Some text</description> </report> ... (6 Replies)
Discussion started by: Ophiuchus
6 Replies

7. Shell Programming and Scripting

help fixing awk statement

awk "BEGIN {if($MessageREAD<$ThresholdW) {print \"OK\" ; exit 0} else if(($MessageREAD>=$ThresholdW) && ($MessageREAD<$ThresholdC)) {print \"WARNING\" ; exit 1}" else if($MessageREAD<=$ThresholdC) {print \"CRITICAL\" ;... (4 Replies)
Discussion started by: SkySmart
4 Replies

8. Hardware

Files getting corrupted

$ uname -a Linux darksun 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:45 UTC 2014 i686 athlon i686 GNU/Linux My files are getting corrupted on a frequent basis. $ sudo fdisk -l /dev/sda Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total... (10 Replies)
Discussion started by: rlopes
10 Replies
Text::vCard::Addressbook(3pm)				User Contributed Perl Documentation			     Text::vCard::Addressbook(3pm)

NAME
Text::vCard::Addressbook - a package to parse, edit and create multiple vCards (RFC 2426) SYNOPSIS
use Text::vCard::Addressbook; my $address_book = Text::vCard::Addressbook->new({ 'source_file' => '/path/to/address.vcf', }); foreach my $vcard ($address_book->vcards()) { print "Got card for " . $vcard->fullname() . " "; } DESCRIPTION
This package provides an API to reading / editing and creating multiple vCards. A vCard is an electronic business card. This package has been developed based on rfc2426. You will find that many applications (Apple Address book, MS Outlook, Evolution etc) can export and import vCards. READING IN VCARDS
load() use Text::vCard::Addressbook; # Read in from a list of files my $address_book = Text::vCard::Addressbook->load( ['foo.vCard', 'Addresses.vcf']); This method will croak if it is unable to read in any of the files. import_data() $address_book->import_data($value); This method imports data directly from a string. new() # Read in from just one file my $address_book = Text::vCard::Addressbook->new({ 'source_file' => '/path/to/address.vcf', }); This method will croak if it is unable to read in the source_file. # File already in a string my $address_book = Text::vCard::Addressbook->new({ 'source_text' => $source_text, }); # Create a new address book my $address_book = Text::vCard::Addressbook->new(); Looping through all vcards in an address book. foreach my $vcard ($address_book->vcards()) { $vcard->...; } METHODS
add_vcard() my $vcard = $address_book->add_vcard(); This method creates a new empty Text::vCard object, stores it in the address book and return it so you can add data to it. vcards() my $vcards = $address_book->vcards(); my @vcards = $address_book->vcards(); This method returns a reference to an array or an array of vcards in this address book. This could be an empty list if there are no entries in the address book. set_encoding() $address_book->add_vcard('utf-8'); This method will add the string ';charset=utf-8' to each and every vCard entry. That does help in connection with e.g. an iPhone... export() my $vcf_file = $address_book->export() This method returns the vcard data in the vcf file format. Please note there is no validation, you must ensure that the correct nodes (FN,N,VERSION) are already added to each vcard if you want to comply with RFC 2426. This might not escape the results correctly at the moment. AUTHOR
Leo Lapworth, LLAP@cuckoo.org COPYRIGHT
Copyright (c) 2003 Leo Lapworth. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ACKNOWLEDGEMENTS
The authors of Text::vFile::asData for making my life so much easier. SEE ALSO
Text::vCard, Text::vCard::Node perl v5.10.1 2011-01-11 Text::vCard::Addressbook(3pm)
All times are GMT -4. The time now is 02:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy