[wellylug] curly csv formatting
Mark Signal
mark at databackup.co.nz
Mon Jul 12 23:53:13 NZST 2004
You mean you can understand that? - it looks like you fell asleep on the
keyboard....
I will try it tomorrow on the 110,000 line csv file and let you know what
happens.
If you know sed can you figure out how to use it to convert windows paths to
cygwin paths?
eg %USERPATH% under xp = c:\Documents and Settings\mark
rsync under cygwin wants to see this : "/cygdrive/c/Documents and
Settings/mark"
Ideally I need to be able to dynamically generate the correct path for
different users logging on.
(usernames do not always tie in with userpaths due to account renaming).
something like: (this is in a bat file on the xp box)
set BACKUPDIR=`%USERPATH%\some\other\subdirs | sexy sed script`
rsync -va %BACKUPDIR% /cygdrive/c/destination
cheers
Mark
-----Original Message-----
From: wellylug-admin at lists.naos.co.nz
[mailto:wellylug-admin at lists.naos.co.nz]On Behalf Of jumbophut
Sent: Monday, 12 July 2004 11:35 p.m.
To: wellylug at lists.naos.co.nz
Subject: Re: [wellylug] curly csv formatting
On Fri, 09 Jul 2004 11:21:02 +1200, Mark Signal wrote:
> Hi
>
> I have to provide a client with a filtered data dump of an old paradox
> database so that they can import the data into their new sap database. I
> have dumped the filtered data into a csv file (110,000 lines) and
formatted
> it using my clutsy perl scripting.
>
I know you've solved the problem by now, but I felt the compelling
need to do this in sed. Why? Well, just because sed is cool.
Save what is below the line to a text file, say /tmp/sed. Then invoke
with: sed -n --file=/tmp/sed datafile
IMHO, the script looks quite beautiful (artistically, not programmatically).
It works for me on this test data:
Smith, John Trevor, 2 March 1934, BA, French and Economics
, , , BCA, Commercial Law
Simpson, Michael Jones, 3 June 1985, BSc, Chemistry
, , , BCA, Management
Cheers
Tony
________________________________________________
: a
/^[ \t]*\([^,]\+\),\([^,]\+\),\([^,]\+\),\(.*\)$/b b
/^[ \t]*,[ \t]*,[ \t]*,\(.*\)$/b c
q
: b
/^[ \t]*\([^,]\+\),\([^,]\+\),\([^,]\+\),\(.*\)$/p
s/^[ \t]*\([^,]\+\),\([^,]\+\),\([^,]\+\),\(.*\)$/\1,\2,\3/
h
n
b a
: c
s/^[ \t]*,[ \t]*,[ \t]*\(,.*\)$/\1/
H
x
s/\n//
p
n
b a
--
Wellington Linux Users Group Mailing List: wellylug at lists.naos.co.nz
To Leave: http://lists.naos.co.nz/mailman/listinfo/wellylug
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.712 / Virus Database: 468 - Release Date: 27/06/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.712 / Virus Database: 468 - Release Date: 27/06/2004
More information about the wellylug
mailing list