|Perl: the Markov chain saw|
enoeding iso 8859 issue within a datadumpby Perlbeginner1 (Scribe)
|on Oct 06, 2012 at 11:09 UTC||Need Help??|
Perlbeginner1 has asked for the
wisdom of the Perl Monks concerning the following question:
with the Mechanize i get a dataset with the following set:
see a datachunk:
Loosdorftown Ledochowskastra�e 4 3382 Loosdorftown Telefonnummer: 02754 6257 FAX-Nummer: 02754 6257-4
the script below gives back result like this one;
Telefonnummer: 0002754 6257
FAX-Nummer: 0002754 6257-4
Well - we have following options here:
to print to a file instead of printing at the screen, we just have to change:
print $OUT_FILE $text;
Some explanations: where $OUT_FILE will be a filehandle for the output file that we will have to open before getting into the so called "for loop".
This would work for the code as it is, but it might be different if we are using the Text:CSV module which has probably dedicated functions or methods for printing CSV lines to a file (Well to be frank i don't use this module and don't know it, although I should probably change this because I am using CSV files from time to time . Well i try to describe more in details what we want to have: Which output file to look like. Well i want the comma to separate the fields of the addresses, or the records?
if we take this for example: katholisch.at
we have the following dataset:
well i want to have seperated each datset into these bits - in other words: if i have a dataset that delimiters and seperates the lines that are given like that
Loosdorf Ledochowskastra�e 4 3382 Loosdorf Telefonnummer: 02754 6257 FAX-Nummer: 02754 6257-4
i would be very very happy. Note: there also a Encoding issues is: see the Ledochowskastra�e - there is a sign in it "▀" so we have to take care for the iso 8859 encoding dont we!?
Well i love if you can give some hints and helping hands. That would be very very supportive. Note;: this is a great gerat chance f or me to learn alot about Perl, and the options and power of Mechanize.
see more results:
Marias Neustift Neustifttown 28 4443 Marias Neussstift Telefonnummer: 007250/204 FAX-Nummer: 07250/204-4 E-Mail: firstname.lastname@example.org
Marias Puchheim Gmundnertown Stra�e 1b 4800 Attnanger-Puchheim Telefonnummer: 007674/62334 FAX-Nummer: 07674/62334-4 E-Mail: email@example.com
Marias Scharten Schartenstown 1 4612 Schartensbook Telefonnummer: 007272/5210
Marias Schmolln Maria Schmollntown 2 5241 Maria Schmolln Telefonnummer: 007743/2209-12 FAX-Nummer: 07743/2209-17 E-Mail: firstname.lastname@example.org
Mattighofen R�merstra�e 12 5230 Mattighofentown Telefonnummer: 007742/2273 0676/87765221 FAX-Nummer: 07742/2273-22 E-Mail: email@example.com
Mauerkirchens Pfarrhofstra�e 4 5270 Mauerkirchentown Telefonnummer: 007724/2262
well you see - we ve have a encoding iso 8859 issue here.
waht can we do!? At the end of the day - i have to get all in a CVS formate