Devam Ediyor

Perl script to match text in different files

We need a simple Perl script.

Basically this is what needs to be done:

Each line in file 1 must be matched against those in the file 2 and inserted into file 2 immediately after the closest match.

Format of the files:

File 1 "Newdata.txt" is a list of addresses. All lines in this file contain one to four segments of text. Each segment is separated by a comma. Some segments contain 3 segments and others contain all 4.

Here is an example:

NEWCASTLE/UNIV NEWCASTLE,FAC MED & HLTH SCI,HLTH SERV FLIGHT 302,RAAF BASE WILLIAMTOW

Segment 1: Format is LOCATION/INSTITUTION NAME. Maximum length of this segment is 51 characters

Segment 2: Maximum length is 30 characters

Segment 3: Maximum length is 20 characters

Segment 4: Maximum length is 20 characters

This file is not sorted in any order and may be sorted if necessary.

File 2 "Database.txt"

This is a quite large file with more than 200,000 lines sorted by different address groups. Each address group is separated by a blank line and the first line of the each group ends with a colon and a letter code with one to three characters. All the other lines are in the same format as those in Newdata.txt.

This is what needs to be done in detail:

For nearly all the lines in [url removed, login to view] file, there is almost an identical line in the Database.txt. However, the match in the database file may contain only 19 characters (instead of 20) for segments 3 and 4.

Therefore, the Perl script should match:

segment 1 exactly as it is in both files

segment 2 exactly as it is in both files

segment 3, if there is one, up to the first 19 characters in both files

segment 4, if there is one, up to the first 19 characters in both files

Once the match is found, the line should be inserted immediately after the closest match in the [url removed, login to view] and must be removed from the Newdata.txt. Those not matched are left in Newdata.txt.

Also, whenever a line is inserted into the [url removed, login to view] please mark it with * , preferably at the beginning of the line, so we can check the accuracy of the script.

Please make sure that the Perl script will not alter the existing data or the order of each line in Database.txt.

I have included the two sample files and the first 11 lines in "Newdata.txt" do have a match in "Database.txt". For example, the line 1 in [url removed, login to view] matches the line 3 in [url removed, login to view], except for the last character in segment 3.

Beceriler: Perl

Daha fazlasını görün: perl match text file, perl match line, perl match file, match text file perl, match file perl, perl search file, perl match text, match files perl, perl match, perl script match files, perl script match text different files, perl match files, perl match line file, perl script match, perl match text files, perl search text file, perl script match file, match text perl, script match text, perl match script, perl script diff files, text files match numbers, match lines text files perl, matching files perl, perl search match file

İşveren Hakkında:
( 6 değerlendirme ) Canberra, Australia

Proje NO: #130764

Seçilen:

dims

Can do it easy

1 gün içinde 50$ USD
(99 Değerlendirme)
5.9

8 freelancer bu iş için ortalamada 60$ teklif veriyor

gasparch

I have more than 7 years of perl programming experience, so this is not a difficult task at all. With best regards, Gaspar Chilingarov

in 3 gün içinde100$ USD
(13 Değerlendirme)
4.7
mickalo

should be a fairly easy task to accomplish. - Mickalo

1 gün içinde 75$ USD
(3 Değerlendirme)
3.9
goodperlcoder

Good job for perl programmer.

in 0 gün içinde50$ USD
(11 Değerlendirme)
3.9
nadeem2005

Dear Sir, I am experienced perl developer. I have already completed a number perl jobs successfully. I have gone through your given project description. I can provide the solution in one day.

1 gün içinde 30$ USD
(11 Değerlendirme)
3.8
Ellemer

Hello, I'm ready to start right now

1 gün içinde 35$ USD
(3 Değerlendirme)
2.2
piotrfirlej

details on pm!

in 2 gün içinde40$ USD
(0 Değerlendirme)
0.0
HashInc

This is an easy task.

in 3 gün içinde100$ USD
(0 Değerlendirme)
0.0