You are here:  » How can I parse this file?


How can I parse this file?

Submitted by jimpannell on Thu, 2009-11-19 14:42 in

Hi David

I'm trying to parse a file in a sort of CSV format and having problems (see beginning of file below):

#!/usr/bin/perl
print"Content-type: text/html\n\n<html></html>";
__END__
6¡999¡1077626825¡1156145987¡6_2.jpg¡6_1.jpg¡6_3.jpg¡6_4.jpg¡6_5.jpg¡¡¡¡¡¡Bargain in Burgundy¡Macon¡Charolles¡2005/11/10¡57 000¡2 ruins on a large plot of land close to a very quiet village.¡
41¡999¡1089468366¡1089470520¡41_1.jpg¡41_2.jpg¡41_3.jpg¡41_4.jpg¡41_5.jpg¡¡¡¡¡¡Beautiful 4 bedroom farm, barn and land in Dordogne¡Mussidan¡Perigueux¡2004/07/10¡313 200¡Superb 4 bedroom restored farm with a barn, a beautiful well and 1700 sq.m of land planted with trees on the edge of a forrest.¿0a ¡This superb 2 levels - 4 bedroom restored farm comes with a 120 sq.m barn¡

As you can see, the delimiter is this "¡" which looks like an upside down exclamation mark. As it's not ascii, can you suggest how I might be able to deal with it?

Many thanks for a great product and totally first class support!

Jim

Submitted by support on Thu, 2009-11-19 15:18

Hi Jim

The separator appears to be extended ASCII character code 161 (hex A1). In addition; you can make use of the skip parameter to ignore the first 3 lines. So to parse this data, have a go using the Format String:

csv|161|0|0|3

Hope this helps!
Cheers,
David.

Submitted by jimpannell on Thu, 2009-11-19 15:36

Guess what? It's working like a charm! Thanks so much.

I've Tweeted about how good this script is btw. Hopefully it'll bring you some business.

Cheers

Jim